Hello folks. I have the following expect function ...
# multiplatform
f
Hello folks. I have the following expect function
expect fun String.formatPlatform(vararg args: Any?): String
and on iosMain module I wrote the actual function
Copy code
actual fun String.formatPlatform(vararg args: Any?): String {
    return NSString.create(format = this, args = arrayOf(args)).toString()
}
But when I compile that code I get this error :
kotlin.Array<out kotlin.Any?>  is not supported here: doesn't correspond to any C type
I tried to change the parameter type from expect function to Float or Double, but the error continues:
kotlin.Array<out kotlin.Float?>  is not supported here: doesn't correspond to any C type
I read the issue https://github.com/JetBrains/kotlin-native/issues/1834 but I do not solve the problem. Can anyone help me with that? Thank you.
l
You at least miss the spread operator (
*
). Look at this comment in the issue: https://github.com/JetBrains/kotlin-native/issues/1834#issuecomment-484854268
f
@louiscad I think so not When I add the spread operator the Android Studio show me a warning :
Redundant spread (*) operator
and the error is the same.
Copy code
actual fun String.formatPlatform(vararg args: Any?): String {
    return NSString.create(format = this, args = *arrayOf(args)).toString()
}
l
Same issue when using
stringWithFormat
?
f
Yes.
Copy code
actual fun String.formatPlatform(vararg args: Any?): String {
    return NSString.stringWithFormat(format = this, args = arrayOf(args))
}
type kotlin.Array<out kotlin.Any?> is not supported here: doesn't correspond to any C type
l
Looks like what you want is impossible, so you'll need to hardcode every time for iOS until there's a better solution.
f
yeah, I am watching that issue in youtrack. Thank you