Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
Hi,

I have a NSTimer which is fired on a button click, such as:

Code:
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(start) userInfo:nil repeats:NO];

now i want to stop the timer before the actual method is called when a different button is clicked....Meaning, the first button has been pushed and the timer has been fired (5 second delay), but the other button has been pushed and stops the timer in it's track before executing the method.

Is this possible?
 
Is this possible?
It is. Just realize that scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: returns a new NSTimer object. Store that and then take a peak at NSTimer's Class Reference to see if there's an instance method that can help you with the stopping part.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.