Skip to content

Instantly share code, notes, and snippets.

@pizthewiz
Created January 16, 2014 19:39
Show Gist options
  • Save pizthewiz/8461905 to your computer and use it in GitHub Desktop.
Save pizthewiz/8461905 to your computer and use it in GitHub Desktop.
Returns a new array containing the receiving array’s elements that are not present in another array.
@interface NSArray (SCRAdditions)
- (NSArray*)objectsNotInArray:(NSArray*)array;
@end
@implementation NSArray (SCRAdditions)
- (NSArray*)objectsNotInArray:(NSArray*)array {
NSMutableArray* list = [[NSMutableArray alloc] init];
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
if ([array containsObject:obj]) {
return;
}
[list addObject:obj];
}];
return list;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment