Instance Method

subdataWithRange:

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

Declaration

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

Parameters

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.

Discussion

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.

NSDataSearchOptions

Options for method used to search data objects.