ObjectiveSugar
ObjectiveSugar copied to clipboard
RFE: add "all" / "every" method to collections
I miss this simple addition:
- (BOOL)all:(BOOL (^)(id object))condition;
i.e:
NSArray *list = @['a', 'b', 'c'];
BOOL allMatch = [list all:^(id object) { return id != nil }];
assert( allMatch );
Sorry, ditto "any" which returns YES if any one of the elements matches the condition, and returns eagerly as soon as the first match is found.
Isn't that -select ?
No, it's detect with BOOL result. Detect works but this is nice counterpart to every :)
Is this functionality already in there ?
there's a PR #69, so closing this one