Christian Würthenr
10/25/2022, 11:04 AMNSData and need to get the first two and the last two bytes out of it…any clue how I can do that? Below gives me the first two, but I don’t see any way to offset the bytes pointer by length - 2 to get the last two
private fun NSData.isCompleteJpeg(): Boolean {
val byteArray = ByteArray(2)
byteArray.usePinned {
memcpy(it.addressOf(0), bytes, 2)
}
....
}Christian Würthenr
10/25/2022, 11:15 AMreinterpret to get a UByte pointer and the you can use the [] to get a certain index
val x = bytes!!.reinterpret<UByteVar>()
val s1 = x[0]
val s2 = x[1]
val e1 = x[length.toInt() - 2]
val e2 = x[length.toInt() - 1]natario1
10/25/2022, 11:20 PMChristian Würthenr
10/26/2022, 6:38 AMChristian Würthenr
10/26/2022, 6:38 AM