Contents

tokenFieldCell(_:shouldAdd:at:)

Allows the delegate to validate the tokens to be added to the receiver at a given index.

Declaration

@MainActor optional func tokenFieldCell(_ tokenFieldCell: NSTokenFieldCell, shouldAdd tokens: [Any], at index: Int) -> [Any]

Parameters

  • tokenFieldCell:

    The token field cell that sent the message.

  • tokens:

    An array of tokens to be inserted in the receiver at index.

  • index:

    The index of the receiver in which the array of tokens to be validated (tokens) will be inserted.

Return Value

An array of validated tokens.

Discussion

The delegate can return the array unchanged or return a modified array of tokens. To reject the add completely, return an empty array. Returning nil causes an error.

See Also

Editing a Tokenized Strings