Hello guys, I have function in common that returns `ByteArray` but on the iOS world it is converted...
d
Hello guys, I have function in common that returns
ByteArray
but on the iOS world it is converted to
KotlinByteArray
and not to
NSData
. In the Kotlin world I have the following extensions to convert
ByteArray
to
NSData
and visceversa.
Copy code
private fun ByteArray.toNSData(): NSData = memScoped {
    return NSData.create(
        bytes = toCValues().getPointer(this),
        length = size.toUInt()
    )
}

private fun NSData.toByteArray(): ByteArray = memScoped {
    val size = length.toInt()
    val nsData = ByteArray(size)
    memcpy(nsData.refTo(0), bytes, size.toUInt())
    return nsData
}
Does someone know how I can convert
KotlinByteArray
to
NSData
and visceversa in Swift? πŸ™‚
r
Wait, why can’t you just call your Kotlin extension in Swift?
πŸ™Œ 1
j
you could do that, but they shouldn't be marked private then of course
πŸ‘ 1
d
I did not think about that LOL πŸ˜…
Thanks @ribesg! πŸ€œπŸ€›