Cannot invoke initializer for ty
2016-11-15 本文已影响367人
Code匠
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)