A position in a text container—that is, an index into the backing string in a text-display view.


class UITextPosition : NSObject


Classes that adopt the UITextInput protocol must create custom UITextPosition objects for representing specific locations within the text managed by the class. The text input system uses both these objects and UITextRange objects for communicating text-layout information. There are two reasons for using objects for text positions rather than primitive types such as NSInteger:

  • Some documents contain nested elements (for example, HTML tags and embedded objects) and you need to track both absolute position and position in the visible text.

  • The WebKit framework requires that text indexes and offsets be represented by objects.

The simplest of UITextPosition objects—for example, one used in plain text—might have a single integer property that represents an offset into a string. If you adopt the UITextInput protocol, you must create a custom UITextRange subclass as well as a custom UITextPosition subclass.

This class declares no methods of its own.


Inherits From

Conforms To

See Also


class UITextRange

A range of characters in a text container, identified by a starting index and an ending index in string backing a text-entry object.

class UITextSelectionRect

An encapsulation of information about a selected range of text in a document.