How do I prevent duplicate select from an Array in an NSTokenField. I've implemented the delegate completionsForSubstring.
The best method I would say is to implement the delegate shouldAddObjects
. Write the following code in the delegate.
NSString *newVal = [[tokens objectAtIndex:0] description];
NSArray *aray = [tokenField objectValue];
for (NSString * token in aray) {
@try{
if ([token isEqual:newVal]){
return nil;
}
}
@catch (NSException *exception) {
;
}
}