gpt4 book ai didi

swift4 - 将非转义值转换为 'T' 可能允许它转义 Xcode 10 Swift CGPath

转载 作者:行者123 更新时间:2023-12-04 02:57:18 25 4
gpt4 key购买 nike

我有这段代码,它在 Xcode 9 中运行良好,但在 Xcode 10 中我收到了这个错误。 将非转义值转换为 'T' 可能允许它转义

这是代码:

extension CGPath {

func forEach( body: @convention(block) (CGPathElement) -> Void) {
typealias Body = @convention(block) (CGPathElement) -> Void
let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CGPathElement>) -> Void = { (info, element) in
let body = unsafeBitCast(info, to: Body.self)
body(element.pointee)
}
print(MemoryLayout.size(ofValue: body))
let unsafeBody = unsafeBitCast(body, to: UnsafeMutableRawPointer.self)
self.apply(info: unsafeBody, function: unsafeBitCast(callback, to: CGPathApplierFunction.self))
}

我收到此 2 行代码的错误
 print(MemoryLayout.size(ofValue: body))
let unsafeBody = unsafeBitCast(body, to: UnsafeMutableRawPointer.self)

内存布局 unsafeBitCast

最佳答案

您将添加 @转义

func forEach( body: @escaping @convention(block) (CGPathElement) -> Void) {

}

关于swift4 - 将非转义值转换为 'T' 可能允许它转义 Xcode 10 Swift CGPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52337614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com