我想UINT16轉換爲UINT8數組,但我得到了以下錯誤消息:如何將UInt16轉換爲Swift 3中的UInt8?
「初始化」不可用:使用「withMemoryRebound(到:容量:__)」來 暫時查看內存作爲另一個佈局兼容型。
代碼:
let statusByte: UInt8 = UInt8(status)
let lenghtByte: UInt16 = UInt16(passwordBytes.count)
var bigEndian = lenghtByte.bigEndian
let bytePtr = withUnsafePointer(to: &bigEndian) {
UnsafeBufferPointer<UInt8>(start: UnsafePointer($0), count: MemoryLayout.size(ofValue: bigEndian))
}