Reputation: 1757
I have a NSMutableArray consisting of several elements. From this array I want to pick out only those elements that contains the word "example" in any form (words such as exampleId, putexample or getexampleId).
How can this be done?
Upvotes: 0
Views: 303
Reputation: 163268
You can use the filterUsingPredicate:(NSPredicate *)predicate
method:
NSMutableArray *myArray = ...
NSString *nameSearch = ...
[myArray filterUsingPredicate:[NSPredicate predicateWithFormat:@"name CONTAINS %@", nameSearch]];
For more information about NSPredicate
, check out the Predicate Programming Guide.
Upvotes: 2