Appsicode
Appsicode

Reputation: 27

How do I Add a searchbar with NSPredicate

I am getting an error when add the

-(void) statement.

"use of undeclared identifier "filterContentForSearchText"

//start of Predicate
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"SELF contains[cd] %@",
                                    searchText];

    searchResults = [recipes filteredArrayUsingPredicate:resultPredicate];
}

end of search

Upvotes: 0

Views: 684

Answers (1)

vishy
vishy

Reputation: 3231

Have a look at this sample, made using NSPredicate if your array doesn't contain this kind of data, show us your data or array handling, which type of data you are having in your array.

Upvotes: 1

Related Questions