views:

22

answers:

0

Hi all,

I'm using the following code for my search on my table:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    [searchParent removeAllObjects]; 
    for(NSString *a in parent)
    {
    NSComparisonResult result = [a compare:searchText options:(NSCaseInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
    if(result == NSOrderedSame){
        [searchParent addObject:a];
    }
    }


}

It's working fine, however, only for one character.

I get the following in the console:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'

Any help is appreciated greatly!

Thanks