EDIT: Revision of question, narrowed the scope
I need to use a switch statement to direct outcomes based on the int value of an NSNumber. My method looks like this:
-(BOOL)setImage:(NSNumber*)c{
switch ([c intValue]){...}
}
I get a “EXC_BAD_ACCESS” error on the switch when I run it
I have also tried switch([c integerValue]) but that doesn’t work either
If I place a static int in the switch statement, the program runs fine.
What’s wrong and how can I get the int value of my NSNumber?
If
[c intValue]crashes thencisn’t an object pointer. If it returns an unexpected value, it’s probablynil. It is a good idea to check for that, and either returnNOfornilnumbers or choose some default value.