I defined an enumeration in the class header file:
typedef enum{
RED = 0,
BLUE,
Green
} Colors;
- (void) switchTest:(Colors)testColor;
and in the implementation file:
- (void) switchTest:(Colors)testColor{
if(testColor == RED){
NSLog(@"Red selected");
}
switch(testColor){
case RED:
NSLog(@"Red selected again !");
break;
default:
NSLog(@"default selected");
break;
}
}
My code compiles correctly without warrnings. When calling the switchTest method with RED, the output is: "Red selected"
, but as soon as the first line of the switch starts, the application unexpectedly quits and without errors / errors.
I am not opposed to using if / else syntax, but I would like to understand my mistake.
source
share