Reputation: 301
Bit of a noob here.
I am developing an app that plays some looped sounds. I would like to give the user the ability to shut down the app after a certain amount of time using a timer. The idea is the user presses a button and the app will shut down once the timer runs out.
At the moment if the button is pressed, the app crashes.
Here's what I got so far:
- (IBAction)timer:(id)sender{
timer = [NSTimer scheduledTimerWithInterval: 10.0 target:self selector:@selector(targetMethod:) userInfo:nil repeats: YES];
}
-(void) targetMethod: (NSTimer*) theTimer {
NSLog(@"timer?");
exit(0);
}
Upvotes: 0
Views: 300
Reputation: 14777
You need to properly define your timer reference:
NSTimer *timer = [NSTimer scheduledTimerWithInterval: 10.0 target:self selector:@selector(targetMethod:) userInfo:nil repeats: YES];
Upvotes: 1