Avoid crash by NSNull objects with NSDictionary+Verified
In some cases, when you download a JSON object from an API, some field is null or empty, and you check:
if ([JSON objectForKey:aKey]) ...
it returns a NSNull object instead nil, thus a non-null object which pass the "if" checking but it's really nothing,
with this method you'll not have more NSNull shit anymore.
- (id)verifiedObjectForKey:(id)aKey;
Written by Alejandro Rupérez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xcode
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#