Created
May 15, 2012 23:55
-
-
Save cbowns/2706112 to your computer and use it in GitHub Desktop.
Nil-guarded dictionary key-value retrieval for JSON responses
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
// JSON is dangerous, take one of these! | |
+ (id)nullGuardedDict:(NSDictionary *)dict valueForKey:(NSString *)key; | |
{ | |
id obj = nil; | |
obj = [dict valueForKey:key]; | |
if (obj == [NSNull null]) { | |
obj = nil; | |
} | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment