Swift 3.0中 UnsafePointer<T> 类型转换

前端之家收集整理的这篇文章主要介绍了Swift 3.0中 UnsafePointer<T> 类型转换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

参考苹果官网

根据官网指导跳转

https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md


找到了Conversion between pointers指针类型转换


代码如下:

// Before:
let untypedPointer = UnsafePointer<Void>(ptr)

// After:
let untypedPointer = ptr.map(UnsafePointer<Void>.init)

// Usually the pointee type is actually inferred:
foo(ptr.map(UnsafePointer.init))
原文链接:https://www.f2er.com/swift/322721.html

猜你在找的Swift相关文章