A text field that converts text into visually distinct tokens.


class NSTokenField : NSTextField


Use a token field when you want typed text to be transformed into "tokens", which are visually distinct elements in the text field interface. For example, you might use a token field in a mail app to display email addresses for individual users. The distinct appearance of tokens makes them easy for users to distinguish from surrounding text.

NSTokenField uses an NSTokenFieldCell to implement much of the control’s functionality. NSTokenField provides cover methods for most methods of NSTokenFieldCell, which invoke the corresponding cell method.


Configuring the Token Style

var tokenStyle: NSTokenField.TokenStyle

The token style of the receiver.

Configuring the Tokenizing Character Set

var tokenizingCharacterSet: CharacterSet!

The recevier’s tokenizing character set to characterSet.

class var defaultTokenizingCharacterSet: CharacterSet

Returns the default tokenizing character set.

Configuring the Completion Delay

var completionDelay: TimeInterval

The receiver’s completion delay.

class var defaultCompletionDelay: TimeInterval

Returns the default completion delay.

Getting and Setting the Delegate

var delegate: NSTokenFieldDelegate?

Returns the token field’s delegate.


enum NSTokenField.TokenStyle

The NSTokenStyle constants define how tokens are displayed and editable in the NSTokenFieldCell. These values are used by tokenStyle and the delegate method tokenFieldCell(_:styleForRepresentedObject:).