Nstimer, is a love and hate class, easy to use, but casually may refer to the loop, memory leaks naturally needless to say;
How convenient to use Nstimer, here a small summary of the next, write the wrong welcome point.
The first is the habit problem, in order to prevent write wrong, I usually put nstimer related to a separate function inside.
As follows:
-(void) inittimer{ if(_timer) { [self cleartimer]; } = [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (Test) Userinfo:nil repeats: YES];} -(void) cleartimer{ [_timer finalize]; = Nil;} -(void) test{ NSLog (@ "timer! ");}
Also, you can try the initialization once and use it until Dealloc is released, so you need to pause it.
Here's how:
-(void) stratanimationtimer{ -(void) pauseanimationtimer{ [_ Animationtimer setfiredate:[nsdate distantfuture];}
Set the trigger time [NSDate distantfuture], paused, how to pause, trigger time distantfuture, do not understand their translation to ~ ~ ~
How to get started? [NSDate Date], immediately trigger it!
ios-nstimer-pause-Pause-Reference loop