---
title: "tokenFieldCell(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstokenfieldcelldelegate/tokenfieldcell(_:completionsforsubstring:indexoftoken:indexofselecteditem:)"
---

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

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

## Declaration

```swift
@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

Return Value An array of strings that are possible completions.

## Discussion

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

## See Also

### Editing a Tokenized Strings

- [tokenFieldCell(_:editingStringForRepresentedObject:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:editingstringforrepresentedobject:).md)
- [tokenFieldCell(_:representedObjectForEditing:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:representedobjectforediting:).md)
- [tokenFieldCell(_:shouldAdd:at:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:shouldadd:at:).md)
