Hello. I am trying to condense my code for a method and was wondering how I would achieve the following:
I have a bunch of variables that differ only in their number such as:
int intVariable1
int intVariable2
UILabel Label1
UILabel Label2
BOOL bool1
BOOL bool2
etc.
So I want to call a method and pass in an int. That int would determine which ints, UILablels, and BOOLs get worked on. So if a 1 was passed in the method would work on these variables like this:
- (void) DyanamicMethod: (int) inputNumber {
//something that uses the inputNumber to act on the 1 variables
intVariable1 = someValue;
[Label1 setText:someText];
bool1 = YES;
}
Obviously if a 2 were passed in I would want the variables to be of the 2 type. I'm assuming you would do something with creating a string somehow, but I'm not sure how to adjust that to use it to become a variable name. Any insight would be appreciated. Thank you for your time.