forked from mirkokiefer/LivelyBlocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollectionIterators.h
27 lines (22 loc) · 1002 Bytes
/
CollectionIterators.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Created by Mirko Kiefer (http://www.mirkokiefer.com) on 3/14/11.
#import <Foundation/Foundation.h>
@interface NSArray(NSArrayIterators)
- (void)forEach: (void (^)(id each))block;
- (void)forEachIndexed: (void (^)(id each, NSUInteger index))block;
- (void)forEachWithOffset:(NSUInteger)offset stepSize:(NSUInteger)stepSize block: (void (^)(id each))block;
- (NSArray*)filter: (BOOL (^)(id each))block;
- (NSArray*)filterIndexed: (BOOL (^)(id each, NSUInteger index))block;
- (NSArray*)collect: (id (^)(id each))block;
- (NSArray*)collectIndexed: (id (^)(id each, NSUInteger index))block;
- (NSArray *)reversedArray;
- (BOOL)all:(BOOL (^)(id each))block;
- (BOOL)any:(BOOL (^)(id each))block;
- (id)objectForPredicate:(BOOL (^)(id each))block;
@end
@interface NSDictionary(NSDictionaryIterators)
- (void)keysAndValues: (void (^)(id key, id value))block;
@end
@interface NSNumber(NSNumberIterators)
- (void)forEach: (void (^)())block;
- (void)forEachIndexed: (void (^)(NSInteger each))block;
@end