I want to filter an array with NSPredicate and I have some issues with it.
I have an NSArray named "recipes" where are saved my data.
Here my code :
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"SELF contains[cd] %@",
searchText];
NSArray *searchRecipe = self.recipe[0];
searchResults = [searchRecipe filteredArrayUsingPredicate:resultPredicate];
}
When i run this code, i get the following error :
2014-01-20 15:40:16.729 Recipes Editor[909:60b] -[filteredArrayUsingPredicate:]: unrecognized selector sent to instance 0x15666f80
2014-01-20 15:40:16.735 Recipes Editor[909:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[filteredArrayUsingPredicate:]: unrecognized selector sent to instance 0x15666f80'
*** First throw call stack:
(0x2f997f4b 0x39dd86af 0x2f99b8e7 0x2f99a1cb 0x2f8e94d8 0x12d01 0x12eeb 0x322fe3d9 0x3213f713 0x3213f6b3 0x3213f691 0x3212b11f 0x322fe149 0x321491cf 0x322bf261 0x322be807 0x322fdf77 0x322be525 0x302c67db 0x3214cdd9 0x322be453 0x32134a49 0x3037be9b 0x2f963183 0x2f962653 0x2f960e47 0x2f8cbc27 0x2f8cba0b 0x345f2283 0x3216f049 0x130c1 0x3a2e0ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Why filteredArrayUsingPredicate can't filter my array ?
thx
self.recipe[0]does not seem to be anNSArrayitself. But turn on debugging information and the problem will disclose itself. - user529758