- (void) addCountDownTimer {
if(self.timer != nil) {
[self.timer invalidate];
self.timer = nil;
}
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startCountDown) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
- (void) startCountDown {
_allCount -= 1000;
NSTimeInterval courrentAllCount = _allCount / 1000;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:courrentAllCount];
// DateTools 第三方框架
self.statusMsgLb.text = [NSString stringWithFormat:@"剩%@%@", [date formattedDateWithFormat:@"dd天HH时"],_countTitle];
if (0 >= _allCount) {
[self removeCountDownTimer];
}
}
// 移除定时器
- (void) removeCountDownTimer {
if(self.timer != nil) {
[self.timer invalidate];
self.timer = nil;
}
}