Expression is not an integer constant expression in iOS objective c -
i want use following expression
-(void)switchcondn{ int expression; int match1=0; int match2=1; switch (expression) { case match1: //statements break; case match2: //statements break; default: // statements break; } but got

when research found
in order work in objective-c, should define constant either this: #define txt_name 1 or better, this: enum {txt_name = 1}; i have been using methods since long time . variable value change in run time need define in others way , didn't want use if else there way of declaration variable others way
i have had study following
objective c switch statements , named integer constants
the error expression not integer constant expression means says: in case, value must constant, in, not variable.
you change declarations above switch constants:
const int match1=0; const int match2=1; or use enumeration. or #define. can't use non-constant variables there.
Comments
Post a Comment