Pointers fast: target UnsafeMutableBufferPointer

Currently searching for quick pointers.

UnsafePointerand UnsafeMutablePointerprovide a pointer to a byte. Using pointer arithmetic, you can access the rest of the bytes.

Something similar can be done with the help UnsafeMutableBufferPointerthat has the endIndex parameter. So, what is the advantage / difference of using UnsafeMutableBufferPointerover UnsafeMutablePointerwhen accessing, for example, bytes in NSData?

+4
source share
1 answer

UnsafeMutablePointer<T>designed to access a single type element T. Its interface is designed to access a single scalar value.

UnsafeMutableBufferPointer<T>, , T, . , (, generate).

NSData, UnsafePointer , . , UnsafeBufferPointer, , .

+1

Source: https://habr.com/ru/post/1598578/


All Articles