UnsafePointer<UInt8> initializer in Swift 3
In Swift 3, you cannot init an
UnsafePointer
using anUnsafeRawPointer
.You can use
assumingMemoryBound(to:)
to convert anUnsafeRawPointer
into anUnsafePointer<T>
. Like this:var ptr = data.bytes.assumingMemoryBound(to: UInt8.self)
Use
debugDescription
ordistance(to:)
to compare two pointer.while(ptr.debugDescription < endPtr.debugDescription)
or
while(ptr.distance(to:endPtr) > 0)