NSData -> [UInt8]

Swift 2.3

    let dataArray: [UInt8] = Array(UnsafeBufferPointer
        (start: UnsafePointer(data.bytes),
        count: data.length))

Swift 3

let data = "foo".data(using: .utf8)!
let array = data.withUnsafeBytes {
     [UInt8](UnsafeBufferPointer(start: $0, count: data.count))
}

你可能感兴趣的:(NSData -> [UInt8])