NSTimer * timer;
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerStart:) userInfo:nil repeats:YES];
[timer setFireDate:[NSDate distantFuture]]; //定时器暂停
[timer setFireDate:[NSDate distantPast]]; //继续
=========定时器最后的销毁
-(void)dealloc{
if ([timer isValid ])
{
[timer invalidate]; //关闭定时器
timer = nil;
}
}
//取消定时器
[timer invalidate];
}
网友评论