The method runs every 60 seconds when the application is running.

I want one of my methods to start every 60 seconds when my application starts, how would I do it?

+5
source share
2 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");
}
+8
source

As long as the answer is correct, your question is incomplete.

Why do you need to run this method regularly? If he needs to poll iCal for tasks every 60 seconds, this is not the best solution. What you need to do is watch the notifications that are stored in the CalCalender out store

0
source

All Articles