Instance Method

enumerateBytes(_:)

Enumerate through each range of bytes in the data object using a block.

Declaration

func enumerateBytes(_ block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)

Parameters

block

The block to apply to byte ranges in the array.

The block takes three arguments:

bytes

The bytes for the current range. This pointer is valid until the data object is deallocated.

byteRange

The range of the current data bytes.

stop

A reference to a Boolean value. The block can set the value to true to stop further processing of the data. The stop argument is an out-only argument. You should only ever set this Boolean to true within the Block.

Discussion

The enumeration block is called once for each contiguous region of memory in the receiver (once total for a contiguous NSData object), until either all bytes have been enumerated, or the stop parameter is set to true.