Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

NSTimer and UIPicker sounds

aceiswildaceiswild Posts: 62Registered Users
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.

Here is my starting point with the NSTimer and array selection.


-(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];
}
Post edited by aceiswild on
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!

Replies

This discussion has been closed.