NSTokenField delegate: ( - tokenField:shouldAddObjects:atIndex: ) doesn't work when it is plain style

131 views Asked by At

i have NSTokenField in my app. i want it in plain style (just want accept one value not more). so i want validate input text from array by using delegate - tokenField:shouldAddObjects:atIndex: but when style in plain , this delegate not run. when i put back style to default. it works.

it my delegate code

- (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index
{
    NSMutableArray *validTokens = [NSMutableArray array];
    NSArray *supplierNames = [ary_suppliersFinal valueForKey:@"SupplierName"];   
    for (NSString *oneToken in tokens)
    {
        if ([supplierNames containsObject:oneToken ])
        {
            [validTokens addObject:oneToken];
        }
    }
    return validTokens;
}

what is wrong? what should i do to make NSTokenField in plain style , only accpet one token, validate token from an array?

0

There are 0 answers