EDIT: Solved :white_check_mark: Hey I have an ex...
# multiplatform
r
EDIT: Solved Hey I have an extension function for iOS where I convert
NSData
to
ByteArray
. However when trying to call it from Swift, it doesn’t show up in the function list suggestions This function has been set in the iOS source set and I’ve re-compiled both projects again and still not working Could it be that I might not be thinking of something that needs to be done aside from creating the function and compiling?
The function on iOS source set
Copy code
public fun NSData.toByteArray(): ByteArray = ByteArray(this@toByteArray.length.toInt()).apply {
    usePinned {
        memcpy(it.addressOf(0), this@toByteArray.bytes, this@toByteArray.length)
    }
}
The call
NSData(data: imageData).toByteArray()
Huh, the function seems to be generated but its receiver is not
NSData
specifically.. Guess it’s expected, but could it be that is not accessible specifically from
NSData
?
Well,
Data
type doesn’t seem to be working neither
Ah I got it, so it generates a “static class” that you can use to invoke “normal” functions. It doesn’t generate extension functions in Swift
I was trying to call it as an extension function 😄