I have a few audio files in a UIPickerView and when i select a sound and push a button it plays fine. But now I'm trying to integrate an NSTimer... So basically you select the sound you want from the UIPicker and press the start button for the NSTimer and when it counts to zero it plays that selected sound. I can get it to work perfectly with a single audio file but I'm having some troubles with multiple files. They are all arrays.
Any suggestions of tips on how i can get this to function with multiple arrays? Anything will help! It has no errors when i run but crashes when the timer gets to zero. I get the SIGABRT.
Here is my starting point with the NSTimer and array selection.
Any suggestions of tips on how i can get this to function with multiple arrays? Anything will help! It has no errors when i run but crashes when the timer gets to zero. I get the SIGABRT.
Here is my starting point with the NSTimer and array selection.
Code:
-(void) countDown {
NSString* buf=[[NSString alloc] initWithFormat:@"%d", count];
count--;
countLabel.text = buf;
[buf release];
if(count == -1) {
NSString *path = [[NSBundle mainBundle] pathForResource: [arraySound objectAtIndex:1] ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
countLabel.text = @" ";
label3.backgroundColor = [UIColor clearColor];
[myTimer invalidate];
}
}
-(IBAction)countDown:(id)sender {
count = 10;
label3.backgroundColor = [UIColor lightGrayColor];
myTimer =[NSTimer scheduledTimerWithTimeInterval: 1
target:self selector:@selector(countDown)
userInfo:nil
repeats:YES];
}