如题,swift5出现以后,这个withUnsafeBytes方法就被弃用了。Xcode提示信息是:
所以,以前的使用方法:
let data = Data()
let value = Int(bigEndian: data.subdata(in: 0..<4).withUnsafeBytes { $0.pointee })
应该改成现在这样:
let data = Data()
let value = Int(bigEndian: data.subdata(in: 0..<4).withUnsafeBytes { $0.baseAddress!.bindMemory(to: Int.self, capacity: 4).pointee })
|