Following an example from Stephan Kochan's book I concocted the following 
method, which alas does not work:


- (IBAction) updateIncrementalSearch:(id)sender {

    NSString * term = [sender stringValue];
    if(term) {
        NSMutableArray * matchResults = [NSMutableArray new];
        
        NSUInteger index = [[self content] indexOfObjectPassingTest:^(RSPerson 
* rsp, NSUInteger idx, BOOL *stop) {
            if([[rsp firstName] caseInsensitiveCompare:term] == NSOrderedSame) {
             //   *stop = YES;
                [matchResults addObject:rsp];
                return YES;
            }
            else {
                return NO;
            }
        }];

#pragma unused(index)

        if([matchResults count]){
            self.matches = [NSArray arrayWithArray:matchResults];
            // throw a notification
        }
        else {
            NSLog(@" [%04d] %s %@",__LINE__,__PRETTY_FUNCTION__, @"no match 
found");
        }
        
        for(RSPerson * p in self.matches) {
            NSLog(@" [%04d] %s %@",__LINE__,__PRETTY_FUNCTION__, p.firstName);
        }
    }
}


This consistently reports 
2012-11-11 14:20:14.050 SearchController[30109:303]  [0105] 
-[RSSearchController updateIncrementalSearch:] (null)

in spite of having 51 records which have firstName values…  And regardless of 
the number of matches which it ought to be generating it returns exactly one 
result each time. (And btw, is it legit to NSLog() from inside a block ?)

What have I missed ? Anyone ?

TIA,
Erik  
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to