Skip to content

Instantly share code, notes, and snippets.



Created May 15, 2012
What would you like to do?
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