Finds and returns the range of the first occurrence of a given string within a given range of the receiver, subject to given options, using the specified locale, if any.
- iOS 2.0+
- macOS 10.5+
- tvOS 2.0+
- watchOS 2.0+
The string for which to search.
A mask specifying search options. The following options may be specified by combining them with the C bitwise
NSAnchored. See String Programming Guide for details on these options.
The range within the receiver for which to search for
The locale argument affects the equality checking algorithm. For example, for the Turkish locale, case-insensitive compare matches “I” to “ı” (
U+0131 LATIN SMALL DOTLESS I), not the normal “i” character.
NSRange structure giving the location and length in the receiver of
a in the receiver, modulo the options in
mask. The range returned is relative to the start of the string, not to the passed-in range. Returns
, 0} if
a is not found or is empty (
NSString objects are compared by checking the Unicode canonical equivalence of their code point sequences. The length of the returned range and that of
a may differ if equivalent composed character sequences are matched.
This method detects all invalid ranges (including those with negative lengths). For applications linked against macOS 10.6 and later, this error causes an exception; for applications linked against earlier releases, this error causes a warning, which is displayed just once per application execution.