---
title: "textField(_:textView:candidatesForSelectedRange:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextfielddelegate/textfield(_:textview:candidatesforselectedrange:)"
---

# textField(_:textView:candidatesForSelectedRange:)

Provides a customized list of candidates to the text view’s candidateListTouchBarItem. This method returns an array of objects that represent the elements of a selection.

## Declaration

```swift
@MainActor optional func textField(_ textField: NSTextField, textView: NSTextView, candidatesForSelectedRange selectedRange: NSRange) -> [Any]?
```

## Discussion

Discussion Invoked from updateCandidates. NSTextView uses the candidates returned from this method and suppress its built-in candidate generation. Returning nil from this delegate method allows NSTextView to query candidates from NSSpellChecker.

## See Also

### Controlling Editing Behavior

- [textField(_:textView:candidates:forSelectedRange:)](appkit/nstextfielddelegate/textfield(_:textview:candidates:forselectedrange:).md)
- [textField(_:textView:shouldSelectCandidateAt:)](appkit/nstextfielddelegate/textfield(_:textview:shouldselectcandidateat:).md)
