A... as I learn Objective C.
There will be close to 20 button on a view at a time... :)
If I use a if/else loop for each button touched, it works great but I consider that to be inelegant and just plain cumbersome.
SO, I am using the button.tag to allow me to assign a number to each button then evaluate each button based on the .tag property.
As I mentioned before, works great with if/else if loops.
But I want to change the tag to a string and then nest it within a NSURL to play a sound. Each button will generate a new tag and consequently a new sound.
As reported by the debugger, I am getting Not a CFSTRING and 'out of bounds' messages and upon stepping through, crashes. Fun, but not blue screen.
Here is the code in question. I humbly request of the Objective C gurus to lend some insight!
int soundNumber = [sender tag];
//soundPick = [NSString stringWithFormat:@"%d", soundNumber]; //remmed out as an alternative try
NSString *soundPick = [[NSNumber numberWithInt:soundNumber] stringValue];
NSURL *aSoundURL = [NSURL fileURLWithPath:[mainBundle pathForResource:soundPick ofType:@"aif"]];
playSound = [[AVAudioPlayer alloc] initWithContentsOfURL:aSoundURL error:&error];
if (!playSound) {
NSLog(@"no Sound for that button: %@", [error localizedDescription]);
}
[playSound play];
*/
Thanks,
Neil