为什么这不起作用:
NSInteger sectionLocation = 0;
NSInteger sectionTitles = 1;
NSInteger sectionNotifications = 2;
switch (section) {
case sectionLocation:
//
break;
case sectionTitles:
//
break;
case sectionNotifications:
//
break;
default:
//
}
我得到这个编译错误:
错误:案例标签不会减少为整数常量
不能像这样使用NSInteger吗?如果是这样,是否有另一种方法可以在 switch 语句中使用变量作为案例?sectionLocation
等具有可变值。