Created
February 23, 2015 14:07
-
-
Save StefanLage/1dcd909907d9b1d53277 to your computer and use it in GitHub Desktop.
Removes each key/value in another given dictionary from the receiving dictionary, if present.
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 NSMutableDictionary (Minus) | |
-(void) minusDictionary:(NSDictionary*)otherDictionary; | |
@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 "NSMutableDictionary+Minus.h" | |
@implementation NSMutableDictionary (Minus) | |
-(void) minusDictionary:(NSDictionary*)otherDictionary{ | |
NSMutableSet *setA = [NSMutableSet setWithArray:self.allKeys]; | |
NSMutableSet *setB = [NSMutableSet setWithArray:otherDictionary.allKeys]; | |
// Get the right keys to remove | |
[setA intersectSet:setB]; | |
[self removeObjectsForKeys:setA.allObjects]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment