我之前曾在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
}
Swift 5.0不推荐使用withUnsafeBytes
.我该怎么解决这个问题?