Je veux convertir UInt16 au tableau UInt8, mais je reçois le message d'erreur suivant:Comment convertir UInt16 en UInt8 en Swift 3?
« init » est disponible: utilisation withMemoryRebound (pour: Capacité: _) 'à afficher temporairement la mémoire comme une autre mise en page -compatible type.
Le code:
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))
}