Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: NSTimer

Have a question... I have Timer

 [NSTimer scheduledTimerWithTimeInterval:120                                                              
target:self                                           
selector:@selector(action1:)                                                      
userInfo:nil                                                       
repeats:YES];

But when I move to another screen of my app I want to change selector...How can I change selector ? I know that I can stop my timer and set a new one, but I don't wont to reset a time remained to fire action...Thanks....

like image 324
Jim Avatar asked Mar 04 '26 14:03

Jim


1 Answers

You can't. NSTimer takes its targeting information in its instantiation methods, and doesn't expose any properties to modify that later.

You're going to have to invalidate this timer and create a new one on the new target.

like image 115
Dan Ray Avatar answered Mar 06 '26 04:03

Dan Ray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!