I am new to Objective-C and I am looking for the eval instruction as I used in Matlab.
If you are not familiar with this, you can create a character string, and then eval this string, which treats it like a line of code.
Here is an example where you want to change the background color of one of the four buttons based on the variable foo, which is = 3, and the buttons will have the name button1, button2, etc.
NSString* buttonEval = [[NSString alloc] initWithFormat:@"[button%d setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];", foo]
Is there an instruction that will evaluate this line as if it were a line of code?
Aaron source share