I have code that works but I want to make sure I am doing things properly and cleanly.
I have four versions of the same collection of views displayed on a screen. Each collection which will be used to control the volume and rate of four different sounds. The collections are linked with IBOutletCollection to 4 different NSArrays (soundView0, soundView1, soundView2, soundView3).
I used the following code to determine which volume slider is being adjusted:
-(IBAction)whichVolume:(UISlider *)sender
{
if ([soundView0 containsObject:sender]) {
soundIndex = 0;
}
else if (([soundView1 containsObject:sender]))
{
soundIndex = 1;
}
else if ([soundView2 containsObject:sender])
{
soundIndex = 2;
}
else if ([soundView3 containsObject:sender])
{
soundIndex = 3;
}
//send a message to set volume of sound at index soundIndex
NSLog(@"The soundIndex is %d", soundIndex);
NSLog(@"The volume is %f", [sender value]);
}
Did I get this right or is there a better way to accomplish this?