Protocol: UITextInputTokenizer

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.Return whether a text position is at a boundary of a text unit of a specified granularity in a specified direction. (required)Return whether a text position is within a text unit of a specified granularity in a specified direction. (required)Return the next text position at a boundary of a text unit of the given granularity in a given direction. (required)Return the range for the text enclosing a text position in a text unit of a given granularity in a given direction. (required)A direction of the text.The granularity of a unit of text.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) isPosition(position, atBoundary:granularity, inDirection:direction)

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

Parameters:

  • position (UITextPosition)

    A text-position object that represents a location in a document.

  • granularity (UITextGranularity)

    A constant that indicates a certain granularity of text unit.

  • direction (UITextDirection)

    A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.

Returns:

  • (Boolean)

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

- (Boolean) isPosition(position, withinTextUnit:granularity, inDirection:direction)

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

Parameters:

  • position (UITextPosition)

    A text-position object that represents a location in a document.

  • granularity (UITextGranularity)

    A constant that indicates a certain granularity of text unit.

  • direction (UITextDirection)

    A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.

Returns:

  • (Boolean)

    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.

- (UITextPosition) positionFromPosition(position, toBoundary:granularity, inDirection:direction)

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

Parameters:

  • position (UITextPosition)

    A text-position object that represents a location in a document.

  • granularity (UITextGranularity)

    A constant that indicates a certain granularity of text unit.

  • direction (UITextDirection)

    A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.

Returns:

  • (UITextPosition)

    The next boundary position of a text unit of the given granularity in the given direction, or nil if there is no such position.

- (UITextRange) rangeEnclosingPosition(position, withGranularity:granularity, inDirection:direction)

Return the range for the text enclosing a text position in a text unit of a given granularity in a given direction. (required) 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.

Parameters:

  • position (UITextPosition)

    A text-position object that represents a location in a document.

  • granularity (UITextGranularity)

    A constant that indicates a certain granularity of text unit.

  • direction (UITextDirection)

    A constant that indicates a direction relative to position. The constant can be of type UITextStorageDirection or UITextLayoutDirection.

Returns:

  • (UITextRange)

    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.