Instance Method

enumerateByteRangesUsingBlock:

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

Declaration

- (void)enumerateByteRangesUsingBlock:(void (^)(const void *bytes, NSRange byteRange, BOOL *stop))block;

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 YES to stop further processing of the data. The stop argument is an out-only argument. You should only ever set this Boolean to YES 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 YES.

See Also

Accessing Underlying Bytes

bytes

A pointer to the data object's contents.

- getBytes:

Copies a data object’s contents into a given buffer.

Deprecated
- getBytes:length:

Copies a number of bytes from the start of the data object into a given buffer.

- getBytes:range:

Copies a range of bytes from the data object into a given buffer.