なぜこれが機能しないのですか?
NSInteger sectionLocation = 0;
NSInteger sectionTitles = 1;
NSInteger sectionNotifications = 2;
switch (section) {
case sectionLocation:
//
break;
case sectionTitles:
//
break;
case sectionNotifications:
//
break;
default:
//
}
このコンパイルエラーが発生します:
エラー:ケースラベルが整数定数に縮小されない
このようなNSIntegerを使用することはできませんか?もしそうなら、switchステートメントのケースとして変数を使用する別の方法はありますか?sectionLocationなどには可変値があります。