<!--
{
  "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/UITextInput/position(within:atCharacterOffset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextInput(im)positionWithinRange:atCharacterOffset:"
  },
  "title" : "position(within:atCharacterOffset:)"
}
-->

# position(within:atCharacterOffset:)

Returns the position within a range of a document’s text that corresponds to the character offset from the start of that range.

```
optional func position(within range: UITextRange, atCharacterOffset offset: Int) -> UITextPosition?
```

## Parameters

`range`

An object that specifies a range of text in a document.

`offset`

A character offset from the start of `range`.

## Return Value

An object that represents a position in a document’s visible text.

## Discussion

You should implement this method if you don’t have a one-to-one correspondence between [`UITextPosition`](/documentation/UIKit/UITextPosition) objects within the given range and character offsets into a document string.

---

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)