---
title: "tokenField(_:representedObjectForEditing:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstokenfielddelegate/tokenfield(_:representedobjectforediting:)"
---

# tokenField(_:representedObjectForEditing:)

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

## Declaration

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

## Parameters

- `tokenField`: The token field that sent the message.
- `editingString`: The edited string representation of a represented object.

## Return Value

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

## Discussion

Discussion 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. note: In OS X v10.4, NSTokenField trims whitespace around tokens but it does not trim whitespace in macOS versions 10.5.0 and 10.5.1. In OS X v10.5.2, you get whitespace-trimming behavior by either linking against the v10.4 binary or linking against the v10.5 binary and not implementing the this method. If you do not want the whitespace-trimming behavior, link against the v10.5 binary and implement this method, returning the editing string if you have no represented object.

## See Also

### Editing a Tokenized Strings

- [tokenField(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)](appkit/nstokenfielddelegate/tokenfield(_:completionsforsubstring:indexoftoken:indexofselecteditem:).md)
- [tokenField(_:editingStringForRepresentedObject:)](appkit/nstokenfielddelegate/tokenfield(_:editingstringforrepresentedobject:).md)
- [tokenField(_:shouldAdd:at:)](appkit/nstokenfielddelegate/tokenfield(_:shouldadd:at:).md)
