<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTokenFieldDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTokenFieldDelegate"
  },
  "title" : "NSTokenFieldDelegate"
}
-->

# NSTokenFieldDelegate

A set of optional methods implemented by delegates of [`NSTokenField`](/documentation/AppKit/NSTokenField) objects.

```
protocol NSTokenFieldDelegate : NSTextFieldDelegate
```

## Topics

### Displaying Tokenized Strings

[`-  tokenField:displayStringForRepresentedObject:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:displayStringForRepresentedObject:))

Allows the delegate to provide a string to be displayed as a proxy for the given represented object.

[`-  tokenField:styleForRepresentedObject:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:styleForRepresentedObject:))

Allows the delegate to return the token style for editing the specified represented object.

### Editing a Tokenized Strings

[`-  tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:))

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

[`-  tokenField:editingStringForRepresentedObject:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:editingStringForRepresentedObject:))

Allows the delegate to provide a string to be edited as a proxy for a represented object.

[`-  tokenField:representedObjectForEditingString:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:representedObjectForEditing:))

Allows the delegate to provide a represented object for the given editing string.

[`-  tokenField:shouldAddObjects:atIndex:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:shouldAdd:at:))

Allows the delegate to validate the tokens to be added to the receiver at a particular location.

### Reading To and Writing From the Pasteboard

[`-  tokenField:readFromPasteboard:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:readFrom:))

Allows the delegate to return an array of objects representing the data read from the specified pasteboard.

[`-  tokenField:writeRepresentedObjects:toPasteboard:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:writeRepresentedObjects:to:))

Sent so the delegate can write represented objects to the pasteboard corresponding to a given array of display strings.

### Managing Menus for Represented Objects

[`-  tokenField:hasMenuForRepresentedObject:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:hasMenuForRepresentedObject:))

Allows the delegate to specify whether the given represented object provides a menu.

[`-  tokenField:menuForRepresentedObject:`](/documentation/AppKit/NSTokenFieldDelegate/tokenField(_:menuForRepresentedObject:))

Allows the delegate to provide a menu for the specified represented object.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSControlTextEditingDelegate`](/documentation/AppKit/NSControlTextEditingDelegate)

[`NSTextFieldDelegate`](/documentation/AppKit/NSTextFieldDelegate)

---

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)