Created
December 14, 2016 04:03
-
-
Save nicolastinkl/8b1aa7ffea9e0657fb660d1a19dd38a9 to your computer and use it in GitHub Desktop.
NSMutNSableDictionary (Safe)
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
@implementation NSMutNSableDictionary(Swizzing) | |
+ (void)load { | |
Class dictCls = NSClassFromString(@"__NSDictionaryM"); | |
Method originalMethod = class_getInstanceMethod(dictCls, @selector(setObject:forKey:)); | |
Method swizzledMethod = class_getInstanceMethod(dictCls, @selector(na_setObject:forKey:)); | |
method_exchangeImplementations(originalMethod, swizzledMethod); | |
} | |
- (void)na_setObject:(id)anObject forKey:(id<NSCopying>)aKey { | |
NSLog(@"anObject : %@ ",anObject); | |
if (!anObject) | |
return; | |
[self na_setObject:anObject forKey:aKey]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment