Apr
3
Day 36: -filterUsingBlock:
Today I’ll highlight a method on NSArray which I’ll be using in the next chapter on NSResponder action. It doesn’t need much further explanation but still I think it’s useful:
- (NSArray *)filterUsingBlock:(BOOL (^)(id object))block
{
return [self filteredArrayUsingPredicate:
[NSPredicate predicateWithBlock:
^(id evaluatedObject, NSDictionary *bindings) {
return block(evaluatedObject);
}]];
}
Excuse the formatting, but that’s what you get with a narrow page design and the long method names from Cocoa.