<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSuggestionsDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "s:6AppKit25NSTextSuggestionsDelegateP"
  },
  "title" : "NSTextSuggestionsDelegate"
}
-->

# NSTextSuggestionsDelegate

A protocol for suggestion delegates of text fields to conform to in order to provide text suggestions in response to the user typing.

```
@MainActor protocol NSTextSuggestionsDelegate<SuggestionItemType> : AnyObject
```

## Topics

### Associated Types

[`associatedtype SuggestionItemType`](/documentation/AppKit/NSTextSuggestionsDelegate/SuggestionItemType)

The type of the `representedValue` property of the provided suggestion items (`NSSuggestionItem`).

### Instance Methods

[`func appending(some NSTextSuggestionsDelegate<Self.SuggestionItemType>) -> some NSTextSuggestionsDelegate<Self.SuggestionItemType>`](/documentation/AppKit/NSTextSuggestionsDelegate/appending(_:)-1gb8y)

Returns a new text suggestions delegate of the same suggestion item type with the items and behaviors of the receiving delegate and `other` concatenated.
When the returned delegate is connected to a text field, all suggestion items provided from the first suggestions delegate appear before all those from the second suggestions delegate, visually separated by a separator.

[`func appending<T>(some NSTextSuggestionsDelegate) -> some NSTextSuggestionsDelegate<AnyHashable>`](/documentation/AppKit/NSTextSuggestionsDelegate/appending(_:)-5x8a)

Returns a new text suggestions delegate of a different, but `Hashable` suggestion item type with the items and behaviors of the receiving delegate and `other` concatenated.
When the returned delegate is connected to a text field, all suggestion items provided from the first suggestions delegate appear before all those from the second suggestions delegate, visually separated by a separator.

[`func textField(NSTextField, didSelect: Self.Item)`](/documentation/AppKit/NSTextSuggestionsDelegate/textField(_:didSelect:))

Called when an item in the suggestions menu has been selected.

[`func textField(NSTextField, provideUpdatedSuggestions: (Self.ItemResponse) -> Void)`](/documentation/AppKit/NSTextSuggestionsDelegate/textField(_:provideUpdatedSuggestions:))

Called when the text field’s text (or tokens) have changed and when the text field is going to display a new list of suggestion items.

[`func textField(NSTextField, textCompletionFor: Self.Item) -> String?`](/documentation/AppKit/NSTextSuggestionsDelegate/textField(_:textCompletionFor:))

Returns the full completion text for a particular item to use when the item is highlighted or selected.

### Type Aliases

[`typealias Item`](/documentation/AppKit/NSTextSuggestionsDelegate/Item)

A suggestion item with the same suggestion item type as the delegate.

[`typealias ItemResponse`](/documentation/AppKit/NSTextSuggestionsDelegate/ItemResponse)

A suggestion item response with the same generic type as the delegate.

[`typealias ItemSection`](/documentation/AppKit/NSTextSuggestionsDelegate/ItemSection)

A suggestion item section with the same suggestion item type as the controller.

---

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)