try to compare a field returned by web-service and which contains only either the String true or false (YES, it’s STRING and not boolean), so i try to compare it with another string like this :
if ([withOptions isEqualToString:@"true"]) {
annotation.stationLavage=@"with";
}else {
annotation.stationLavage=@"without";
}
so when withOptions string contains the “true” string, all is ok, and when it contains the “false” string i got this exception in the log :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x2984d68'
i am pretty sure that in all cases, withOptions contains a string value (either “true” or “false”) and it never contains NULL.
Clearly, that assumption is wrong. 🙂
On the line before that
if()statement, addNSLog(@"%@ - %@", withOptions, [withOptions class]);Not that
NSNullandNULLare not the same thing;NSNullis a class whose singleton instance represents “no value” in containers (and other things) that don’t acceptnilas values.When that crash occurs,
withOptionsis referring to an instance ofNSNull.