Instance Method


Returns a new data object containing the data object's bytes that fall within the limits specified by a given range.


- (NSData *)subdataWithRange:(NSRange)range;



The range in the receiver from which to get the data. If this range is not within the data object's range of bytes, NSRangeException is raised.

Return Value

A data object containing the receiver’s bytes that fall within the limits specified by range.


A sample using this method can be found in Working With Binary Data.

See Also

Finding Data

- rangeOfData:options:range:

Finds and returns the range of the first occurrence of the given data, within the given range, subject to given options.


Options for method used to search data objects.

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