美文网首页
Cannot invoke initializer for ty

Cannot invoke initializer for ty

作者: Code匠 | 来源:发表于2016-11-15 03:15 被阅读367次

In Swift 3, you cannot init an UnsafePointer using an UnsafeRawPointer.You can use assumingMemoryBound(to:) to convert an UnsafeRawPointer into an UnsafePointer. Like this:

var ptr = data.bytes.assumingMemoryBound(to: UInt8.self)

Use debugDescription or distance(to:) to compare two pointer.

while(ptr.debugDescription < endPtr.debugDescription)

or

while(ptr.distance(to:endPtr) > 0)

ios - UnsafePointer initializer in Swift 3 - Stack Overflow

相关文章

网友评论

      本文标题:Cannot invoke initializer for ty

      本文链接:https://www.haomeiwen.com/subject/gbfkpttx.html