Home > Software engineering >  Cannot convert value of type '[[String]]' to expected argument type 'KotlinArray<K
Cannot convert value of type '[[String]]' to expected argument type 'KotlinArray<K

Time:04-01

I use Kotlin Multiplatform to write a function

    actual fun multiSet(keyValuePairs: Array<Array<String>>) {
        AsyncStorageModule().multiSet(keyValuePairs)
    }

use in iOS with swift

    let storageMultiset = AsyncStorage().multiSet(keyValuePairs: keyValues)

but got error enter image description here

CodePudding user response:

Try to use List instead

actual fun multiSet(keyValuePairs: List<List<String>>) {
        AsyncStorageModule().multiSet(keyValuePairs)
    }

List on Kotlin side becomes NSArray<SomeData *> for iOS (Objc), and in Swift it’ll look like [SomeData]

Array becomes Kotlin Array object wrapping the array like KotlinArray<SomeData *>

So looks like the error you're facing is related to that?

  • Related