Created
September 7, 2015 14:14
-
-
Save YGeorge/0ebf872e69bda28077b0 to your computer and use it in GitHub Desktop.
NSMutableArray+YGHelper
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
[sources removeObjectsWithPredicate:^BOOL(id obj){ | |
LCFTSource *source = (LCFTSource *)obj; | |
return [self.hiddenSourceIDs containsObject:source.sourceID]; | |
}]; |
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
#import <Foundation/Foundation.h> | |
@interface NSMutableArray (YGHelper) | |
- (void)removeObjectsWithPredicate:(BOOL (^)(id obj))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
#import "NSMutableArray+YGHelper.h" | |
@implementation NSMutableArray (YGHelper) | |
- (void)removeObjectsWithPredicate:(BOOL (^)(id obj))predicate { | |
if (predicate != nil) { | |
NSMutableArray *newArray = [[NSMutableArray alloc] initWithCapacity:self.count]; | |
for (id obj in self) { | |
BOOL shouldRemove = predicate(obj); | |
if (!shouldRemove) { | |
[newArray addObject:obj]; | |
} | |
} | |
[self setArray:newArray]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment