I was having trouble with NSTokenFieldCell, so I proceeded to create a new project in Xcode to isolate the problem. Here is what I did:
- Dropped a NSTableView into the main window;
- selected the second column's text cell, and changed it's Class (via Identity Inspector) to NSTokenFieldCell;
implemented a minimum possible data source object, with the following code:
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return 1; } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { return @"aa, bb"; }
At first it seems to work fine, but if you double-click a cell to edit, then tab and shift+tab to switch cells back and forth, eventually the application crashes with a BAD ACCESS when the token field cell receive focus.
I'm using Xcode 4.2 in Lion 10.7.2, with all the default settings that come with a Mac OS X Cocoa Application template.
Looks like a bug in Cocoa. If you turn on zombies you'll see this:
I tried setting a delegate for the table and implementing
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
, returning a newNSTokenFieldCell
every time (for just the token column), but I got the same error.