<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTokenFieldCellDelegate/tokenFieldCell(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTokenFieldCellDelegate(im)tokenFieldCell:completionsForSubstring:indexOfToken:indexOfSelectedItem:"
  },
  "title" : "tokenFieldCell(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)"
}
-->

# tokenFieldCell(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)

Allows the delegate to provide an array of appropriate completions for the contents of the receiver.

```
@MainActor optional func tokenFieldCell(_ tokenFieldCell: NSTokenFieldCell, completionsForSubstring substring: String, indexOfToken tokenIndex: Int, indexOfSelectedItem selectedIndex: UnsafeMutablePointer<Int>) -> [Any]
```

## Parameters

`tokenFieldCell`

The token field cell that sent the message.

`substring`

The partial string that is to be completed.

`tokenIndex`

The index of the token being edited.

`selectedIndex`

Optionally, you can return by-reference an index into the returned array that specifies which of the completions should be initially selected. If none are to be selected, return by reference `-1`.

## Return Value

An array of strings that are possible completions.

## Discussion

If the delegate does not implement this method, no completions are provided.

---

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)