I got an error like this -
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[NSCFDictionary initWithObjects:forKeys:count:]: attempt to insert nil value at objects[0] (key: searched)'
Then I tried the below code
if (Obj == (id)[NSNull null]) //Obj is an id
{
NSLog(@" Obj is (id)[NSNull null]");
}
else if (Obj == nil)
{
NSLog(@"Obj is nil");
}
else if (Obj == NULL)
{
NSLog(@"Obj is NULL");
}
else
{
NSLog(@"Obj is something else");
}
searchedDict = [NSDictionary dictionaryWithObject:Obj forKey:@"searched"];
And I got the NSLog message as 'Obj is nil'.
But when I used the same above code when Obj was NSString and my app got terminated due to nil value, I got the NSLog message as 'Obj is (id)[NSNull null]'.
What are the differences between nil, NULL and [NSNULL nil] ?
Are there different kinds of Null values? if yes, How to check commonly for these null values?
Thanks :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With