Quote:
Originally Posted by Jango
I have this alarm app that activates the timer, in that invalidate works well.
The problem arises when I want to reset the timer before it(alarm) goes on.
invalidate what it does is it stops the receiver from ever firing again and requests its removal from its NSRunLoop object but when the timer is not being started in the first place, in that case invalidate is causing the app to quit.
Any suggestions???
|
Do you need it to be a timer that repeats? If not you can use:
Code:
[self performSelector:@selector(timerFunction) withObject:nil afterDelay:timeInSeconds];
then to stop it you can use:
Code:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(timerfunction) object:nil];
There may be a way to do the same thing with a timer but I am not sure. Also it may not be pretty, but you could just use a BOOL for if the alarm actually goes off and just set that to false to cancel the alarm. Then inside the alarm function don't do anything if the bool is false.