PRECAP: I have followed Why can I not use my constant in the switch - case statement in Objective-C ? but still the problem persists. Also I am not allowed to comment my question in the above link and that is why I put this question again.
In a iOS app, I have constants.h as:
int const Category_Default = 1;
In another file (say test.m) I used it in this way:
switch(//someVariable) {
case Category_Default:
//do something
default:
//do something
}
Unfortunately the compiler gives me an error as Case label does not reduce to an integer constant.
I am aware that the value of a constant must be known at compile time to be able to be used in a case
within a switch
.
I even initialized the constant in the .h file itself as suggested in Why can I not use my constant in the switch - case statement in Objective-C but still the error persists.
NOTE: I don't want to use #define
or enum
in this case.
Any help on this would be much appreciated.