Skip to content

Instantly share code, notes, and snippets.

@cokecoffe
Created September 4, 2014 07:10
Show Gist options
  • Save cokecoffe/c560263d274cb254fc28 to your computer and use it in GitHub Desktop.
Save cokecoffe/c560263d274cb254fc28 to your computer and use it in GitHub Desktop.
NSDictionary (SafeObjectForKey)
@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