Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a Method happen every 60 seconds when the App is running

I'm wanting to make one of my methods to run every 60 seconds when my App is running, how would I do that?

like image 302
Joshua Avatar asked Sep 27 '09 14:09

Joshua


1 Answers

NSTimer

- (void) startTimer
{
  self.myTimer = [NSTimer scheduledTimerWithTimeInterval:60
                                                  target:self
                                                selector:@selector(timerFired:)
                                                userInfo:nil
                                                 repeats:YES];
}

- (void) stopTimer
{
    [self.myTimer invalidate];
}

- (void) timerFired:(NSTimer*)theTimer
{
    NSLog(@"yay");
}
like image 187
slf Avatar answered Oct 05 '22 23:10

slf