【发布时间】:2019-08-18 02:11:34
【问题描述】:
我之前在 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 上已弃用。我该如何解决这个问题?
【问题讨论】:
标签: swift deprecated unsafe-pointers