Diego
02/22/2019, 2:46 PMByteArray
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.
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? 🙂ribesg
02/22/2019, 2:48 PMJonas Bark
02/22/2019, 2:59 PMDiego
02/22/2019, 2:59 PMDiego
02/22/2019, 2:59 PM