Instance Method


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


optional func tokenField(_ tokenField: NSTokenField, representedObjectForEditing editingString: String) -> Any?



The token field that sent the message.


The edited string representation of a represented object.

Return Value

A represented object that is displayed rather than the editing string.


If your application uses some object other than an NSString for their represented objects, you should return a new, autoreleased instance of that object from this method.

See Also

Editing a Tokenized Strings

func tokenField(NSTokenField, completionsForSubstring: String, indexOfToken: Int, indexOfSelectedItem: UnsafeMutablePointer<Int>?) -> [Any]?

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

func tokenField(NSTokenField, editingStringForRepresentedObject: Any) -> String?

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

func tokenField(NSTokenField, shouldAdd: [Any], at: Int) -> [Any]

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