This might be a completely ridiculous question, but is it possible to use a NSString as a substitute for a line of code?
for (int i = 0; i < 10: i++){
NSString *cam = @"locXCamProfileSwitch";
["%@", cam setOn:YES];
]
Also is it possible to concantinate the index i into the replacement of the X?
It’s not generally possible (as far as I know), but it’s possible to access ivars, properties, classes and methods by using strings.
Instance variables and properties can be accessed like this:
Classes can be referenced like this:
Methods can be used like this:
To replace a placeholder in a string with a number you can use a formatter:
That being said, it’s never a good idea to have numbered variable names.
Use an array instead:
Then you can simply iterate over it:
And be notified when one of them changes like this: