Pushed an update to my iOS + Kotlin/Native ergonom...
# feed
b
Pushed an update to my iOS + Kotlin/Native ergonomics post about the new Enum<T>.values() method exposed to Obj-C/Swift in Kotlin 1.4.30: https://benasher.co/kotlin-ios-ergonomics/
🙏 2
🎉 3
K 5
swift 2
l
Hey Ben, thanks for sharing! I tried that with a simple enum but couldn’t make it work. Do I just paste the extension block as you defined? If so, when I try to compile it errors with the following message:
Copy code
Swift.Array:2:23: note: candidate '() -> Array<Element>' requires 0 arguments, but 1 was provided
    @inlinable public init()
b
Hm yeah it compiles and works in my project. Can you provide a larger code sample? Also provide details of your Xcode/Swift version. You're using Kotlin 1.4.30, right?
l
Yeah, 1.4.30 and latest stable Xcode. I pushed a sample here: https://github.com/leandrofavarin/enums-swift It’s probably something really obvious :$
b
Where are you calling the
Array
initializer? I don’t see it
l
I haven’t yet! the compiler fails when i declare the extension inside ContentView.swift 😕
b
Interesting. Busy today, but I can double check it tomorrow
🙏 1
Ha whoops I accidentally used an init that’s an internal extension in our codebase. will fix shortly
pushed a fix to my post. basically just replace that init with:
Copy code
init()
reserveCapacity(Int(array.size))
l
nice, thank you! 🙏