Created
April 9, 2013 20:45
-
-
Save CodaFi/5349243 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSArray+CFIWhere.h | |
// CFIArrayController | |
// | |
// Created by Robert Widmann on 4/9/13. | |
// Copyright (c) 2013 CodaFi. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSArray (CFIWhere) | |
+ (instancetype)arrayWithObjectsFromArray:(NSArray*)sourceArray passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))testBlock; | |
- (NSArray*)where:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (instancetype)arrayWithObjectsFromArray:(NSArray*)sourceArray passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))testBlock { | |
return [sourceArray objectsAtIndexes:[sourceArray indexesOfObjectsPassingTest:testBlock]]; | |
} | |
- (NSArray*)where:(BOOL (^)(id, NSUInteger, BOOL *))testBlock { | |
return [self objectsAtIndexes:[self indexesOfObjectsPassingTest:testBlock]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment