---
title: "positionOfToken(at:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uisearchtextfield/positionoftoken(at:)"
---

# positionOfToken(at:)

Converts a token index into a text position.

## Declaration

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

## Parameters

- `tokenIndex`: The array index of the token.

## Return Value

Return Value The text position of the token.

## Discussion

Discussion Use this method to convert a token’s index in the tokens array into the token’s UITextPosition in the overall contents of the text field. Many UITextInput methods for interacting with text take a UITextPosition or UITextRange (constructed from two text positions) as a parameter. To select a search token, assign a UITextRange that contains the token’s position to the selectedTextRange property.

## See Also

### Customizing token behavior

- [tokenBackgroundColor](uikit/uisearchtextfield/tokenbackgroundcolor.md)
- [tokens(in:)](uikit/uisearchtextfield/tokens(in:).md)
