Instance Method


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


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



The block to apply to byte ranges in the array.

The block takes three arguments:


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


The range of the current data bytes.


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.


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


A pointer to the data object's contents.

- getBytes:

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

- 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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software