range(of:options:in:)
Finds and returns the range of the first occurrence of the given data, within the given range, subject to given options.
Declaration
func range(of dataToFind: Data, options mask: NSData.SearchOptions = [], in searchRange: NSRange) -> NSRangeParameters
- dataToFind:
The data for which to search.
- mask:
A mask specifying search options. The Searchoptions options may be specified singly or by combining them with the C bitwise
ORoperator. - searchRange:
The range within the receiver in which to search for
dataToFind. If this range is not within the data object’s range of bytes, Rangeexception 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.