Hope you can support our Website: http://t.cn/zOdAUxJ to raise comments
Nstcoa is a common Timer class in cocoa. The basic operations are as follows:
The handletimer method can be customized. You can create a timer as needed, and handletimer can be executed every 0.5 seconds.
Example:
-(Void) handletimer: (nstimer *) Timer
{// Processing here} nstimer * timer; timer = [nstimer scheduledtimerwithtimeinterval: 0.5 target: Self selector: @ selector (handletimer :) userinfo: Nil repeats: Yes];
Note:
1: If you do not want to cycle timer, change the code
Repeats: No
2. After nstcount initialization, add retaincount of self to 1.
Then, we need to execute [Timer invalidate] before releasing this class; otherwise, the dealloc method of this class will not be executed. 3. When you drag a table (
Stop when uiscrollview is scratched), Timer stopped
- (void)setTimer{NSTimer *timer;NSDate *date = [NSDate date];timer = [[NSTimer alloc] initWithFireDate:date interval:m_ablum.m_displayInterval target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];self.m_timer = timer; [timer release];}
Not updated in nsdefaultrunloopmode.
timer = [[NSTimer alloc] initWithFireDate:date interval:m_ablum.m_displayInterval target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];
When it is set to target, its retaincount plus one .!!!!
Note