Created
September 4, 2014 07:10
-
-
Save cokecoffe/c560263d274cb254fc28 to your computer and use it in GitHub Desktop.
NSDictionary (SafeObjectForKey)
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
@interface NSDictionary (SafeObjectForKey) | |
- (id) safeObjectForKey:(id)aKey; | |
@end | |
@implementation NSDictionary (SafeObjectForKey) | |
- (id) safeObjectForKey:(id)aKey | |
{ | |
id obj = [self objectForKey: aKey]; | |
if ([obj isKindOfClass: [NSNull class]]) { | |
return nil; | |
} | |
return obj; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment