<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextPosition",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITextPosition"
  },
  "title" : "UITextPosition"
}
-->

# UITextPosition

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

```
@MainActor class UITextPosition
```

## Overview

Classes that adopt the [`UITextInput`](/documentation/UIKit/UITextInput) protocol must create custom [`UITextPosition`](/documentation/UIKit/UITextPosition) objects for representing specific locations within the text managed by the class. The text input system uses both these objects and [`UITextRange`](/documentation/UIKit/UITextRange) objects for communicating text-layout information. There are two reasons for using objects for text positions rather than primitive types such as <doc://com.apple.documentation/documentation/ObjectiveC/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`](/documentation/UIKit/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`](/documentation/UIKit/UITextInput) protocol, you must create a custom [`UITextRange`](/documentation/UIKit/UITextRange) subclass as well as a custom [`UITextPosition`](/documentation/UIKit/UITextPosition) subclass.

This class declares no methods of its own.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)