Last active
August 29, 2015 13:57
-
-
Save tonyarnold/9700369 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // Created by Tony Arnold on 22/03/2014. | |
| // Copyright (c) 2014 The CocoaBots. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface NSArray (CocoaBotsAdditions) | |
| - (NSSet *)tcb_objectsPassingTest:(BOOL (^)(id obj, BOOL *stop))predicate; | |
| - (NSArray *)tcb_arrayOfObjectsPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate; | |
| @end |
This file contains hidden or 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
| // | |
| // Created by Tony Arnold on 22/03/2014. | |
| // Copyright (c) 2014 The CocoaBots. All rights reserved. | |
| // | |
| #import "NSArray+CocoaBotsAdditions.h" | |
| @implementation NSArray (CocoaBotsAdditions) | |
| - (NSSet *)tcb_objectsPassingTest:(BOOL (^)(id obj, BOOL *stop))predicate | |
| { | |
| NSSet *allObjects = [NSSet setWithArray:self]; | |
| return [allObjects objectsPassingTest:predicate]; | |
| } | |
| - (NSArray *)tcb_arrayOfObjectsPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate | |
| { | |
| NSIndexSet *passingIndexes = [self indexesOfObjectsPassingTest:predicate]; | |
| return [self objectsAtIndexes:passingIndexes]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment