How can I check if an object in an NSArray is NSNull?
id object = myArray[0];// similar to [myArray objectAtIndex:0]
if(![object isEqual:[NSNull null]])
{
//do something if object is not equals to [NSNull null]
}
if (myArray != (id)[NSNull null])
OR
if(![myArray isKindOfClass:[NSNull class]])
Building off of Toni's answer I made a macro.
#define isNSNull(value) [value isKindOfClass:[NSNull class]]
Then to use it
if (isNSNull(dict[@"key"])) ...
Awww, guys. This is an easy one.
// if no null values have been returned.
if ([myValue class] == [NSNull class]) {
myValue = nil;
}
I'm sure there are better answers, but this one works.