Some of the things that the timer often uses
1. Initialization
Timer = [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (changetime:) Userinfo:nil <span Style= "Font-family:arial, Helvetica, Sans-serif;" > repeats:yes];</span>
2.timer Run Now
[Tiemr fire];
Assuming that this code is not added at initialization time, the timer will run back immediately.
3. Timer Expiration
[Timer invalidate];<pre name= "code" class= "html" >timer = nil; When the timer fails, it's best to empty it.
After this failure is not another time to use the timer, it is equivalent to a timer useless. To continue using a timer can only initialize the timer again
4.timer Pause
[Timer setfiredate:[nsdate distantfuture];
5.timer pause and start again
[Timer setfiredate:[nsdate Distantpast];
6.timer Method Transfer
The number of passes is an ID type, and we generally put all the passes in the nsdictionary.
Nsdictionary *dic = [nsdictionary dictionarywithobject:[nsstring stringwithformat:@ "%i", AnimIndexPath] forKey:@ " Animindexpath "]; Timer = [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (changetime:) Userinfo:dic repeats: YES];
In the method that the timer runs
-(void) Changetime: (Nstimer *) tme{ int soundlength = [[Tme userInfo] objectforkey:@ "Animindexpath"] intvalue]; }}
So we can get the number of the passes.
7. Infer if the timer is executing
if ([timer isValid]) { [timer invalidate]; Timer = nil; }
iOS series--nstimer