我之前在Swift 4.2中使用这段代码生成id:
public static func generateId() throws -> UInt32 {
let data: Data = try random(bytes: 4)
let value: UInt32 = data.withUnsafeBytes { $0.pointee } // deprecated warning!
return value // + some other stuff
}
withUnsafeBytes
在 Swift 5.0 中已被弃用。我该如何解决?
Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)
错误,我们该如何处理它? - Jack