如何将此代码迁移到Swift 3?
let keyBytes = keyData.bytes.bindMemory(to: Void.self, capacity: keyData.count)
我收到以下错误
'bytes'不可用:改为使用withUnsafeBytes
答案 0 :(得分:2)
keyData
是Data
对象的类型,没有属性bytes
,将keyData
转换为NSData
,然后访问bytes
let keyBytes = NSData(data: keyData).bytes.bindMemory(to: Void.self, capacity: keyData.count)