tl;dr
You should check for NSNull
aside from checking for nil
.
PFFile * imageFile = object[@"goal_image"]; // note the modern Obj-C syntax
if (imageFile && ![image isEqual:[NSNull null]]) {
...
}
Explanation
NSNull
is different from nil
, the first one being an object.
Since NSArray
and NSDictionary
only hold objects, nil
cannot be stored in such containers and that's why NSNull
is used, typically to represent a null
value returned in the JSON response.
Sending messages to nil
fails silently, whereas sending an unrecognized selector to the NSNull
singleton will result in a crash.
Also remember that objectForKey:
will return nil
in case the key is not found in the dictionary.