为什么不这项工作:为什么我不能在switch语句中使用NSInteger?
NSInteger sectionLocation = 0;
NSInteger sectionTitles = 1;
NSInteger sectionNotifications = 2;
switch (section) {
case sectionLocation:
//
break;
case sectionTitles:
//
break;
case sectionNotifications:
//
break;
default:
//
}
我得到这个编译错误:
error: case label does not reduce to an integer constant
是没可能使用NSInteger的是这样的?如果是这样,是否有另一种方法在switch语句中使用变量作为例子? sectionLocation
等有可变值。
因此,我将不得不诉诸的if-else-if-else语句来着?这有没有解决办法? – Rits 2011-01-08 19:14:00