A position in a text container—that is, an index into the backing string in a text-display view.
- iOS 3.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
Classes that adopt the
UIText protocol must create custom
UIText objects for representing specific locations within the text managed by the class. The text input system uses both these objects and
UIText 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 requires that text indexes and offsets be represented by objects.
The simplest of
UIText 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
UIText protocol, you must create a custom
UIText subclass as well as a custom
This class declares no methods of its own.