Stop the NSTimer

Discussion in 'iOS Programming' started by jjgraz, Sep 29, 2009.

  1. jjgraz macrumors regular

    jjgraz

    Joined:
    Feb 13, 2009
    #1
    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?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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.
     

Share This Page