Instance Method


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


- (NSRange)rangeOfData:(NSData *)dataToFind options:(NSDataSearchOptions)mask range:(NSRange)searchRange;



The data for which to search.


A mask specifying search options. The NSDataSearchOptions options may be specified singly or by combining them with the C bitwise OR operator.


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

Return Value

An NSRange structure giving the location and length of dataToFind within searchRange, modulo the options in mask. The range returned is relative to the start of the searched data, not the passed-in search range. Returns {NSNotFound, 0} if dataToFind is not found or is empty.

See Also

Finding Data

- subdataWithRange:

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


Options for method used to search data objects.