Implement NSTokenField
Delegate tokenField:shouldAddObjects:atIndex:
// return an array of represented objects you want to add.
// If you want to reject the add, return an empty array.
- (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index
{
if (index>2) {
return [NSArray array];
}
NSLog(@"%@-- %d %d", tokens, [tokens count],index);
return tokens;
}