核心就是在控制器中创建计时器,然后在模型中倒计时时间
//计时器
- (void)setUpTimer {
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerEvent) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
- (void)timerEvent {
for (CZHCountDownModel *timeModel in self.timeArrays) {
if (timeModel.startTime - timeModel.currentTime <= 0) {
continue;
}
[timeModel countDown];
[[NSNotificationCenter defaultCenter] postNotificationName:CZHUpdateTimeNotification object:nil];
}
}
公司的项目,求支持,如果发现什么问题,可以留言反应,感激不尽