November 2013
Beginner
325 pages
9h 47m
English
When you filter a collection, you compare its objects to a logical statement to get a resultant collection that only contains objects for which the statement is true.
A predicate contains a statement that might be true, like “The employeeID is greater than 75.” There is a class called NSPredicate. NSMutableArray has a handy method for discarding all the objects that do not satisfy the predicate:
- (void)filterUsingPredicate:(NSPredicate *)predicate;
With NSArray, you cannot remove objects that do not match the predicate. Instead, NSArray has a method that creates a new array that contains all the objects that satisfy the predicate:
- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate;
Imagine that ...
Read now
Unlock full access