@property(nonatomic,strong)NSTimer *timer;
_timer = [NSTimer scheduledTimerWithTimeInterval:2 repeats:YES block:^(NSTimer * _Nonnull timer) {
//要执行的事件
}];
开始执行定时器:[_timer setFireDate:[NSDate distantPast]];
暂停执行定时器:[_timer setFireDate:[NSDate distantFuture]];
结束定时器:[_timer invalidate];
网友评论