<!--
{
  "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/insertToken(_:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISearchTextField(im)insertToken:atIndex:"
  },
  "title" : "insertToken(_:at:)"
}
-->

# insertToken(_:at:)

Adds a search token at a specific index.

```
func insertToken(_ token: UISearchToken, at tokenIndex: Int)
```

## Parameters

`token`

The search token to be inserted.

`tokenIndex`

Within the [`tokens`](/documentation/UIKit/UISearchTextField/tokens) array, the index at which to insert the token.

## Discussion

If you’re converting part of the search field’s text into a token, use [`replaceTextualPortion(of:with:at:)`](/documentation/UIKit/UISearchTextField/replaceTextualPortion(of:with:at:)).

---

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)