These higher-order methods mutate the receiver collection in-place.
- - (id) map
Returns a proxy object on which methods can be called. These methods will cause each element in the collection to be replaced with the return value of the method call.
- - (id) filter
Returns a proxy object on which methods with return type BOOL can be called. Only elements that respond with YES to the method call will remain in the collection. If there are any object returning messages sent to the proxy before the predicate, these messages will be applied to the elements in the collection before the test is performed. It is thus possible to filter a collection based on attributes of an object: [[[persons filter] firstName] isEqual: @"Alice"]
The returned boolean that corresponds to the last message is undetermined. For example, the code below is meaningless: if ([[[persons filter] firstName] isEqual: @"Alice"]) doSomething;
- - (id) filterOut
Filters a collection the same way -filter does, but only includes objects that respond with NO to the predicate.
- (id) zipWithCollection: (id
Returns a proxy object which will coalesce the collection named by aCollection into the first collection by sending all messages sent to the proxy to the elements of the receiver with the corresponding element of aCollection as an argument. The first argument of the message (after the implicit receiver and selector arguments) is thus ignored. The operation will stop at the end of the shorter collection.
- - (void) mapWithBlock: (id)aBlock
Replaces each element in the collection with the result of applying aBlock to it. The blocks takes one argument of type id.
- (void) zipWithCollection: (id
)aCollection andBlock: (id)aBlock
Coalesces the second collection into the first by applying aBlock (where aBlock takes two arguments of type id) to all element pairs. Processing will stop at the end of the shorter collection.
- - (void) filterWithBlock: (BOOL(^)(id))aBlock
Removes all elements from the collection for which the aBlock does not return YES.