Start and Stop NSTimer to perform a task

/ Published in: Objective C
Save to your folder(s)

Copy this code and paste it in your HTML
  1. // Create a timer that call taskToUpdate every 1.0 sec
  2. NSTimer timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(taskToUpdate) userInfo:nil repeats:YES];
  5. // Stop the timer if it's running
  6. // (no way to "stop it" and "run it back", you must "kill it" and "recreate it")
  7. if([timer isValid]){
  8. [timer invalidate];
  9. timerAffcheur = nil;
  10. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.