UITextInputTokenizer Protocol Reference
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 3.2 and later. |
| Declared in | UITextInput.h |
Overview
An instance of a class that adopts the UITextInputTokenizer protocol is a tokenizer; a tokenizer allows the text input system to evaluate text units of different granularities. Granularities of text units are always evaluated with reference to a storage or reference direction.
Text-processing objects that conform to the UITextInput protocol must hold a reference to a tokenizer (via the tokenizer property). The UITextInputStringTokenizer class of the UIKit framework provides a default base implementation of the UITextInputTokenizer protocol. Tokenizers of this class are suitable for most western-language keyboards. Applications with different requirements may adopt the UITextInputTokenizer protocol and create their own tokenizers.
Tasks
Determining Text Positions Relative to Unit Boundaries
-
– isPosition:atBoundary:inDirection:required method -
– isPosition:withinTextUnit:inDirection:required method
Computing Text Position by Unit Boundaries
-
– positionFromPosition:toBoundary:inDirection:required method
Getting Ranges of Specific Text Units
-
– rangeEnclosingPosition:withGranularity:inDirection:required method
Instance Methods
isPosition:atBoundary:inDirection:
Return whether a text position is at a boundary of a text unit of a specified granularity in a specified direction. (required)
Parameters
- position
A text-position object that represents a location in a document.
- granularity
A constant that indicates a certain granularity of text unit.
- direction
A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.
Return Value
YES if the text position is at the given text-unit boundary in the given direction; NO if it is not at the boundary.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.hisPosition:withinTextUnit:inDirection:
Return whether a text position is within a text unit of a specified granularity in a specified direction. (required)
Parameters
- position
A text-position object that represents a location in a document.
- granularity
A constant that indicates a certain granularity of text unit.
- direction
A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.
Return Value
YES if the text position is within a text unit of the specified granularity in the specified direction; otherwise, return NO. If the text position is at a boundary, return YES only if the boundary is part of the text unit in the given direction.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.hpositionFromPosition:toBoundary:inDirection:
Return the next text position at a boundary of a text unit of the given granularity in a given direction. (required)
Parameters
- position
A text-position object that represents a location in a document.
- granularity
A constant that indicates a certain granularity of text unit.
- direction
A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.
Return Value
The next boundary position of a text unit of the given granularity in the given direction, or nil if there is no such position.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.hrangeEnclosingPosition:withGranularity:inDirection:
Return the range for the text enclosing a text position in a text unit of a given granularity in a given direction. (required)
Parameters
- position
A text-position object that represents a location in a document.
- granularity
A constant that indicates a certain granularity of text unit.
- direction
A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.
Return Value
A text-range representing a text unit of the given granularity in the given direction, or nil if there is no such enclosing unit. Whether a boundary position is enclosed depends on the given direction, using the same rule as the isPosition:withinTextUnit:inDirection: method.
Discussion
In this method, return the range for the text enclosing a text position in a text unit of the given granularity, or nil if there is no such enclosing unit. If the text position is entirely enclosed within a text unit of the given granularity, it is considered enclosed. If the text position is at a text-unit boundary, it is considered enclosed only if the next position in the given direction is entirely enclosed.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.hConstants
UITextDirection
A direction of the text.
typedef int UITextDirection;
Discussion
This parameter is used in methods declared by the UITextInputTokenizer protocol. This general direction type subsumes constants of the UITextStorageDirection and UITextLayoutDirection types.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.hUITextGranularity
The granularity of a unit of text.
typedef enum {
UITextGranularityCharacter,
UITextGranularityWord,
UITextGranularitySentence,
UITextGranularityParagraph,
UITextGranularityLine,
UITextGranularityDocument
} UITextGranularity;
Constants
UITextGranularityCharacterThe unit of text is a character.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.UITextGranularityWordThe unit of text is a word.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.UITextGranularitySentenceThe unit of text is a sentence.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.UITextGranularityParagraphThe unit of text is a paragraph.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.UITextGranularityLineThe unit of text is a line.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.UITextGranularityDocumentThe unit of text is a document.
Available in iOS 3.2 and later.
Declared in
UITextInput.h.
Discussion
Constants of this type are used as parameters in all methods of the UITextInputTokenizer protocol.
Availability
- Available in iOS 3.2 and later.
Declared In
UITextInput.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-02-25)