Reading Character Array from Shared class in KotlinMultiPlatform (KMM)

286 Views Asked by At

How can I properly read the data from a mutable array in Swift from a Kotlin Module? Kotlin Shared Module:

data class Tape(private val capacity: Int) {
        val reel: MutableList<Char>
        ...
}

Swift:

tape.reel.compactMap({ $0 as? Character } // leads to nothing in the array
1

There are 1 best solutions below

0
Róbert Nagy On

Kotlin Char will be mapped as UInt16

One option might be to map your char list to a string in Kotlin:

val reel: String

Then on the Swift side work with it as a String