Reputation: 85
How can I recall or reestablish a timer that was previously invalidated?
I am trying to allow the user to revalidate/restart a timer when they click a button. Is this possible?
Upvotes: 8
Views: 3403
Reputation: 8576
When you invalidate a timer, set it to nil
. Then you'll be able to point it to a new NSTimer
object.
Example:
//When you're done using your timer
[timer invalidate];
timer = nil;
//When you want to use it again
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(tick) userInfo:nil repeats:TRUE];
Upvotes: 5
Reputation: 3947
Unfortunately, no.
Once invalidated, timer objects cannot be reused.
Just make a new one.
Upvotes: 10