Skip to content

Commit 6bc62e7

Browse files
committed
if we set resetTimerAfterFinish to true, we should call it before calling delegate
because reset will update the label, and if the user change the label in the delegate, it will be override by the reset, which seems not good
1 parent 1b55f9e commit 6bc62e7

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

MZTimerLabel/MZTimerLabel.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,23 @@ -(void)updateLabel{
392392

393393
//0.5.1 moved below to the bottom
394394
if(timerEnded) {
395+
// save the timeUserValue because reset will change it
396+
NSTimeInterval endTimeUserValue = timeUserValue;
397+
398+
// call reset before we call delegate
399+
if(_resetTimerAfterFinish){
400+
[self reset];
401+
}
402+
395403
if([_delegate respondsToSelector:@selector(timerLabel:finshedCountDownTimerWithTime:)]){
396-
[_delegate timerLabel:self finshedCountDownTimerWithTime:timeUserValue];
404+
[_delegate timerLabel:self finshedCountDownTimerWithTime:endTimeUserValue];
397405
}
398406

399407
#if NS_BLOCKS_AVAILABLE
400408
if(_endedBlock != nil){
401-
_endedBlock(timeUserValue);
409+
_endedBlock(endTimeUserValue);
402410
}
403411
#endif
404-
if(_resetTimerAfterFinish){
405-
[self reset];
406-
}
407412

408413
}
409414

0 commit comments

Comments
 (0)