Instance Method

nextWordFromIndex:forward:

Returns the index of the first character of the word after or before the given index.

Declaration

- (NSUInteger)nextWordFromIndex:(NSUInteger)location forward:(BOOL)isForward;

Parameters

index

The index in the attribute string.

flag

YES if the search should be forward, otherwise NO.

Return Value

YES if this is the first character after index that begins a word; if flag is NO, it’s the first character before index that begins a word, whether index is located within a word or not.

Discussion

If index lies at either end of the string and the search direction would progress past that end, it’s returned unchanged.

This method is intended for moving the insertion point during editing, not for linguistic analysis or parsing of text.

Raises an NSRangeException if index lies beyond the end of the receiver’s characters.

See Also

Calculating Linguistic Units

- doubleClickAtIndex:

Returns the range of characters that form a word (or other linguistic unit) surrounding the given index, taking language characteristics into account.

- lineBreakBeforeIndex:withinRange:

Returns the appropriate line break when the character at the index won’t fit on the same line as the character at the beginning of the range.

- lineBreakByHyphenatingBeforeIndex:withinRange:

Returns the index of the closest character before the given index, and within the given range, that can be placed on a new line by hyphenating.