<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISearchTextField/positionOfToken(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISearchTextField(im)positionOfTokenAtIndex:"
  },
  "title" : "positionOfToken(at:)"
}
-->

# positionOfToken(at:)

Converts a token index into a text position.

```
func positionOfToken(at tokenIndex: Int) -> UITextPosition
```

## Parameters

`tokenIndex`

The array index of the token.

## Return Value

The text position of the token.

## Discussion

Use this method to convert a token’s index in the [`tokens`](/documentation/UIKit/UISearchTextField/tokens) array into the token’s [`UITextPosition`](/documentation/UIKit/UITextPosition) in the overall contents of the text field. Many [`UITextInput`](/documentation/UIKit/UITextInput) methods for interacting with text take a [`UITextPosition`](/documentation/UIKit/UITextPosition) or [`UITextRange`](/documentation/UIKit/UITextRange) (constructed from two text positions) as a parameter.

To select a search token, assign a [`UITextRange`](/documentation/UIKit/UITextRange) that contains the token’s position to the [`selectedTextRange`](/documentation/UIKit/UITextInput/selectedTextRange) property.

---

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)