https://kotlinlang.org logo
#feed
Title
# feed
b

basher

02/16/2021, 6:55 PM
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

leandro

02/23/2021, 1:14 PM
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

basher

02/23/2021, 2:27 PM
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

leandro

02/23/2021, 3:06 PM
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

basher

02/23/2021, 3:53 PM
Where are you calling the
Array
initializer? I don’t see it
l

leandro

02/23/2021, 8:07 PM
I haven’t yet! the compiler fails when i declare the extension inside ContentView.swift 😕
b

basher

02/23/2021, 9:11 PM
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

leandro

02/25/2021, 12:26 PM
nice, thank you! 🙏
3 Views