How to check if a BOOL is null?
Posted
by Sheehan Alam
on Stack Overflow
See other posts from Stack Overflow
or by Sheehan Alam
Published on 2010-05-03T18:01:03Z
Indexed on
2010/05/03
18:08 UTC
Read the original article
Hit count: 195
Is there a way I can check to see if a value is NULL/Nil before assigning it to a BOOL?
For example, I have a value in a NSDictionary that can be either TRUE/FALSE/NULL
mySTUser.current_user_following = [[results objectForKey:@"current_user_following"]boolValue];
When the value is NULL I get the following error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSNull boolValue]: unrecognized selector sent to instance
I would like to be able to handle the NULL case.
© Stack Overflow or respective owner