Skip to content

Instantly share code, notes, and snippets.

@cbowns
Created May 15, 2012 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbowns/2706112 to your computer and use it in GitHub Desktop.
Save cbowns/2706112 to your computer and use it in GitHub Desktop.
Nil-guarded dictionary key-value retrieval for JSON responses
// 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