Available in iOS 3.2 and later
UITextPosition object represents a position in a text container; in other words, it is an index into the backing string in a text-displaying view.
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
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, which the iPhone text system is based on, 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
This class declares no methods of its own.