Objective-C - Expression is not an integer constant expression

时间:2015-06-25 19:07:32

标签: ios objective-c

I got this error message when trying to do switch. /Users/xxxxx/Documents/iOS/xxxxx/main.m:83:14: Expression is not an integer constant expression My code char *anotherCharacter = "a"; switch (*anotherCharacter) { case "a": NSLog(@"The letter a"); case "A": NSLog(@"The letter A"); default: NSLog(@"Not the letter A"); }

2 个答案:

答案 0 :(得分:3)

Change "a" to 'a' and "A" to 'A' respectively. 'a' is an integer type actually while "a" is a string

答案 1 :(得分:1)

the switch statement in Objective-C considers only integer values