---
title: Introduction to Token Field Programming Guide for Cocoa
framework: cocoa
role: article
path: apple-archive/documentation/Cocoa/Conceptual/TokenField_Guide/Introduction
---

# Introduction to Token Field Programming Guide for Cocoa

Describes how to set up and programatically manage a token field.

## Token Fields at a Glance

A token field is a text field with tokens as content. A token represents a string or other object.

- **Construction**: Single-cell control - **Classes and inheritance**: Control: `NSTokenField` : `NSTextField` : `NSControl` : `NSView` : `NSResponder` : `NSObject` - Cell: `NSTokenFieldCell` : `NSTextFieldCell` : `NSActionCell` : `NSCell` : `NSObject`

**Design patterns**: Target-action, delegation, key-value observing

**Object attributes**: Tokenizing character set, completion delay, token style

**Important methods**: `objectValue` (NSControl), `tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:` (delegate), `tokenField:representedObjectForEditingString:` (delegate), `tokenField:displayStringForRepresentedObject:`d (delegate), `tokenField:menuForRepresentedObject:` (delegate)

**Important bindings**: value

**Usage guidelines**: Under “Text Controls” in “ <!--a target="_self" -->UI Element Guidelines: Controls<!--/a--> " (*Apple Human Interface Guidelines*)

## Organization of This Document

This document consists of the following chapters:

- [About Token Fields](../TokenFieldPurpose/TokenFieldPurpose.html#//apple_ref/doc/uid/TP40006555-CH3-SW4) describes what token fields are designed to do in a user interface and offers some guidelines for their usage. - [How Token Fields Work](../TokenFieldArchitecture/TokenFieldArchitecture.html#//apple_ref/doc/uid/TP40006555-CH4-SW2) discusses the central concepts and mechanisms of token fields. - [Configuring Token Fields](../TokenFieldsIB/TokenFieldsIB.html#//apple_ref/doc/uid/TP40006555-CH5-SW1) explains how to configure token fields and connect them to other objects in an application. - [Displaying the Completion List](../DisplayComplList/DisplayComplList.html#//apple_ref/doc/uid/TP40006555-CH7-SW2) describes how to display a list of possible completions for the currently entered substring. - [Returning Represented Objects](../ReturnRepObjects/ReturnRepObjects.html#//apple_ref/doc/uid/TP40006555-CH8-SW3) shows how to return an array of represented objects for the tokens in a token field. - [Getting and Setting Token-Field Values](../GetSetTokenFields/GetSetTokenFields.html#//apple_ref/doc/uid/TP40006555-CH9-SW2) shows how to extract and set the contents of a token field. - [Implementing Menus for Tokens](../ImplTokenFieldMenus/ImplTokenFieldMenus.html#//apple_ref/doc/uid/TP40006555-CH10-SW2) discusses how to associate menus with tokens in a token field.

[Next](../TokenFieldPurpose/TokenFieldPurpose.html)

Copyright © 2007 Apple Inc. All Rights Reserved. [Terms of Use](http://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](http://www.apple.com/privacy/) | Updated: 2007-12-11
