<!--
{
  "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/UITextInputTokenizer/position(from:toBoundary:inDirection:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextInputTokenizer(im)positionFromPosition:toBoundary:inDirection:"
  },
  "title" : "position(from:toBoundary:inDirection:)"
}
-->

# position(from:toBoundary:inDirection:)

Return the next text position at a boundary of a text unit of the given granularity in a given direction.

```
func position(from position: UITextPosition, toBoundary granularity: UITextGranularity, inDirection direction: UITextDirection) -> UITextPosition?
```

## Parameters

`position`

A text-position object that represents a location in a document.

`granularity`

A constant that indicates a certain granularity of text unit.

`direction`

A constant that indicates a direction relative to `position`. The constant can be of type UITextStorageDirection or UITextLayoutDirection.

## Return Value

The next boundary position of a text unit of the given granularity in the given direction, or `nil` if there is no such position.

## Discussion

---

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)