Hey. I have an interesting Kotlin-Swift related issue 😄
Let’s say you have an enum in Kotlin:
enum class SomeEnum(val id: String) { VALUE1("value1"), VALUE2("value2") }
which you can instantiate in your Kotlin code via
valueOf
method.
How can I instantiate it in Swift code? Swift doesn’t see
valueOf
method. I’ve tried to add a compation object into an enum, to “fake”
valueOf
method but its not visible on Swift side either.
I guess workaround is to pattern match on Swift side, and just return an instance of
SomeEnum
case:
switch valueInstance {
case "value1": return .value1
case "value2": return .value2
}
Are there any other solutions ? 😄