---
title: "tokenFieldCell(_:representedObjectForEditing:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstokenfieldcelldelegate/tokenfieldcell(_:representedobjectforediting:)"
---

# tokenFieldCell(_:representedObjectForEditing:)

Allows the delegate to provide a represented object for the string being edited.

## Declaration

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

## Parameters

- `tokenFieldCell`: The token field cell 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

- [tokenFieldCell(_:completionsForSubstring:indexOfToken:indexOfSelectedItem:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:completionsforsubstring:indexoftoken:indexofselecteditem:).md)
- [tokenFieldCell(_:editingStringForRepresentedObject:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:editingstringforrepresentedobject:).md)
- [tokenFieldCell(_:shouldAdd:at:)](appkit/nstokenfieldcelldelegate/tokenfieldcell(_:shouldadd:at:).md)
