iOS Developer Library

Developer

UIKit Framework Reference UITextInputTokenizer Protocol Reference

Options
Deployment Target:

On This Page
Language:

UITextInputTokenizer

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. More...

Inheritance


Not Applicable

Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 3.2 and later.
  • Return whether a text position is at a boundary of a text unit of a specified granularity in a specified direction. (required)

    Declaration

    Swift

    func isPosition(_ position: UITextPosition, atBoundary granularity: UITextGranularity, inDirection direction: UITextDirection) -> Bool

    Objective-C

    - (BOOL)isPosition:(UITextPosition *)position atBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction

    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

    YEStrue if the text position is at the given text-unit boundary in the given direction; NOfalse if it is not at the boundary.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Return whether a text position is within a text unit of a specified granularity in a specified direction. (required)

    Declaration

    Swift

    func isPosition(_ position: UITextPosition, withinTextUnit granularity: UITextGranularity, inDirection direction: UITextDirection) -> Bool

    Objective-C

    - (BOOL)isPosition:(UITextPosition *)position withinTextUnit:(UITextGranularity)granularity inDirection:(UITextDirection)direction

    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

    YEStrue if the text position is within a text unit of the specified granularity in the specified direction; otherwise, return NOfalse. If the text position is at a boundary, return YEStrue only if the boundary is part of the text unit in the given direction.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Return the next text position at a boundary of a text unit of the given granularity in a given direction. (required)

    Declaration

    Swift

    func positionFromPosition(_ position: UITextPosition, toBoundary granularity: UITextGranularity, inDirection direction: UITextDirection) -> UITextPosition?

    Objective-C

    - (UITextPosition *)positionFromPosition:(UITextPosition *)position toBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction

    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.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Return the range for the text enclosing a text position in a text unit of a given granularity in a given direction. (required)

    Declaration

    Swift

    func rangeEnclosingPosition(_ position: UITextPosition, withGranularity granularity: UITextGranularity, inDirection direction: UITextDirection) -> UITextRange?

    Objective-C

    - (UITextRange *)rangeEnclosingPosition:(UITextPosition *)position withGranularity:(UITextGranularity)granularity inDirection:(UITextDirection)direction

    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.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

Data Types

  • A direction of the text.

    Declaration

    Swift

    typealias UITextDirection = Int

    Objective-C

    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.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • The granularity of a unit of text.

    Declaration

    Swift

    enum UITextGranularity : Int { case Character case Word case Sentence case Paragraph case Line case Document }

    Objective-C

    typedef enum { UITextGranularityCharacter, UITextGranularityWord, UITextGranularitySentence, UITextGranularityParagraph, UITextGranularityLine, UITextGranularityDocument } UITextGranularity;

    Constants

    • Character

      UITextGranularityCharacter

      The unit of text is a character.

      Available in iOS 3.2 and later.

    • Word

      UITextGranularityWord

      The unit of text is a word.

      Available in iOS 3.2 and later.

    • Sentence

      UITextGranularitySentence

      The unit of text is a sentence.

      Available in iOS 3.2 and later.

    • Paragraph

      UITextGranularityParagraph

      The unit of text is a paragraph.

      Available in iOS 3.2 and later.

    • Line

      UITextGranularityLine

      The unit of text is a line.

      Available in iOS 3.2 and later.

    • Document

      UITextGranularityDocument

      The unit of text is a document.

      Available in iOS 3.2 and later.

    Discussion

    Constants of this type are used as parameters in all methods of the UITextInputTokenizer protocol.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.