Enumerates the substrings of the specified type in the specified range of the string.
- iOS 4.0+
- macOS 10.6+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
The range within the string to enumerate substrings.
Options specifying types of substrings and enumeration styles.
The block executed for the enumeration.
The block takes four arguments:
The enumerated string.
The range of the enumerated string in the receiver.
The range that includes the substring as well as any separator or filler characters that follow. For instance, for lines,
enclosingcontains the line terminators. The
enclosingfor the first string enumerated also contains any characters that occur before the string. Consecutive enclosing ranges are guaranteed not to overlap, and every single character in the enumerated range is included in one and only one enclosing range.
A reference to a Boolean value that the block can use to stop the enumeration by setting
*stop = YES; it should not touch
If this method is sent to an instance of
NSMutable, mutation (deletion, addition, or change) is allowed, as long as it is within
enclosing. After a mutation, the enumeration continues with the range immediately following the processed range, after the length of the processed range is adjusted for the mutation. (The enumerator assumes any change in length occurs in the specified range.)
For example, if the block is called with a range starting at location N, and the block deletes all the characters in the supplied range, the next call will also pass N as the index of the range. This is the case even if mutation of the previous range changes the string in such a way that the following substring would have extended to include the already enumerated range. For example, if the string "Hello World" is enumerated via words, and the block changes "Hello " to "Hello", thus forming "HelloWorld", the next enumeration will return "World" rather than "HelloWorld".