Posted By

funkypanda on 12/02/09


Tagged

timer Task NSTimer


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bobbym245
dvel


Start and Stop NSTimer to perform a task


 / Published in: Objective C
 

  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];
  3.  
  4.  
  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  

Comments

RSS Icon Subscribe to comments
Posted By: paki on May 11, 2011

You're missing a * before timer.. So it should be NSTimer *timer = ...

You need to login to post a comment.