I have the following code in a loop
NSArray * images = [definitionDict objectForKey:@"Images"];
NSLog(@"images in definitionDict %@", images);
if (!images )
NSLog(@"NULL");
else
NSLog(@"NOTNULL");
which gives the following outputs
images in definitionDict (
"/some/brol/brol.jpg"
)
NOTNULL
images in definitionDict <null>
NOTNULL
I do not understand the second case, where the images array is null. Why is this not detected correctly in my test ? How can I debug such a problem ?
<null>is notnil.nilwill print(null)when printed. What you have is anNSNull.NSNullIS an object, it just doesn’t respond to much. Its available as a placeholder for you to use.To test for
NSNullyou can useif ([images isEqual:[NSNull null]])See the docs for more info on
NSNull