ios - Swift 3.0 convert Data to Array<UInt8> -


how convert data array of uint8?

func serialport(_ serialport: orsserialport, didreceive data: data) { print("recieved:\(data)") let arr: [uint8] = data(???)??? } 

log recieved:70 bytes

in swift 3, data works collection of uint8, can use array.init.

var recived: [uint8] = []  func serialport(_ serialport: orsserialport, didreceive data: data) {     print("recieved:\(data))")     recived = array(data) } 

but, array.init (or array.append(contentsof:)) copies content of data, it's not efficient when need work huge size of data.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -