- (void)change:(int)a {
int number = a;
int max = 10;
switch(max) {
case number:
//Do something
break;
//.... more cases
}
}
This is just a small example of the issue I can’t seem to solve. I have looked at similar posts and answers usually include using constants via a #define or enum, however these are great when you have a constant that is fixed but if the value is passed through as a parameter how could I do this? if it’s possible at all. Any advice would be appreciated.
In a nutshell,
casestatements can only operate on constant expressions, so if you need more dynamic conditionals, you will have to useifstatements.