Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

Swift 5.0:不推荐使用'withUnsafeBytes':使用`withUnsafeBytes(...)

在Swift
5中,使用(untyped)调用闭包的

withUnsafeBytes()
方法,您可以从原始内存中获取值:
Data``UnsafeRawBufferPointer
load()

let value = data.withUnsafeBytes { 
Random
.load(as: UInt32.self) }

(在Swift论坛中比较如何以明确定义的方式使用Data.withUnsafeBytes?)。请注意,这要求内存在4字节边界上_对齐_

另请注意,从Swift 4.2开始,您可以使用新

let randomId = UInt32.random(in: .min ... .max)
API轻松创建一个随机的32位整数

[+++]


)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Swift 5.0:不推荐使用'withUnsafeBytes':使用`withUnsafeBytes(...)_随笔_内存溢出

Swift 5.0:不推荐使用'withUnsafeBytes':使用`withUnsafeBytes(...)

Swift 5.0:不推荐使用'withUnsafeBytes':使用`withUnsafeBytes(...),第1张

Swift 5.0:不推荐使用'withUnsafeBytes':使用`withUnsafeBytes(...)

在Swift
5中,使用(untyped)调用闭包的

withUnsafeBytes()
方法,您可以从原始内存中获取值:
Data``UnsafeRawBufferPointer
load()

let value = data.withUnsafeBytes { 
Random
.load(as: UInt32.self) }

(在Swift论坛中比较如何以明确定义的方式使用Data.withUnsafeBytes?)。请注意,这要求内存在4字节边界上_对齐_

另请注意,从Swift 4.2开始,您可以使用新

let randomId = UInt32.random(in: .min ... .max)
API轻松创建一个随机的32位整数



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5666525.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存