What can I do to avoid the app crashing when it encounters a null value?
the error message I get is:
-[NSNull isEqualToString:]: unrecognized selector sent to instance.
I tried this conditional statement to check for a null value, but it still crashes. listingWebAddress is a NSString
.
if (listingWebAddress == nil)
{
[webLabel setText:@""];
} else {
[webLabel setText:listingWebAddress];
}
it works fine when a "listingWebAddress" exists.
thanks for the help :)
Update:
thanks to The Tiger's response the code now works. The solution was:
if (![listingWebAddress isKindOfClass:[NSNull class]])
{
// do your task here
[webLabel setText:listingWebAddress];
} else {
[webLabel setText:@"no web url"];
}