I'm writing a mixer app that has multiple slider objects all with individual tags (from 0 - 5) . Is there a way to change their properties without using a switch statement. For example my code currently has to repeat itself in a load of case statements :
-(void)sliderupdate:(int)currentfader{
switch (currentfader) {
case 0:
channel0 = round(fader0.value*100);
value0.text = [NSString stringWithFormat:@"%2d",channel0];
knob0.center = CGPointMake(...;
mute0.backgroundColor = ...;
break;
case 1:
channel1 = round(fader1.value*100);
value1.text = [NSString stringWithFormat:@"%2d",channel1];
knob1.center = CGPointMake(...;
mute1.backgroundColor = ...;
break;
Can I simply write one expression like:
channel(x) = ....
value(x) = ....
knob(x) = ....
No, but you can add those Channel objects in an NSMutableArray and access them by index. a different array for the values and a different one for knob. like:
[channelArray objectAtIndex:x];
[valueArray objectAtIndex:x];
[knob objectAtIndex:x];
just make sure you add them in the correct oder to their arrays.