From 6bc62e761ef4e8fc1e24a8b0000876eff078f2ae Mon Sep 17 00:00:00 2001 From: liuxuan30 Date: Thu, 5 Nov 2015 18:44:55 +0800 Subject: [PATCH] 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 --- MZTimerLabel/MZTimerLabel.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/MZTimerLabel/MZTimerLabel.m b/MZTimerLabel/MZTimerLabel.m index ee33133..b7a5590 100644 --- a/MZTimerLabel/MZTimerLabel.m +++ b/MZTimerLabel/MZTimerLabel.m @@ -392,18 +392,23 @@ -(void)updateLabel{ //0.5.1 moved below to the bottom if(timerEnded) { + // save the timeUserValue because reset will change it + NSTimeInterval endTimeUserValue = timeUserValue; + + // call reset before we call delegate + if(_resetTimerAfterFinish){ + [self reset]; + } + if([_delegate respondsToSelector:@selector(timerLabel:finshedCountDownTimerWithTime:)]){ - [_delegate timerLabel:self finshedCountDownTimerWithTime:timeUserValue]; + [_delegate timerLabel:self finshedCountDownTimerWithTime:endTimeUserValue]; } #if NS_BLOCKS_AVAILABLE if(_endedBlock != nil){ - _endedBlock(timeUserValue); + _endedBlock(endTimeUserValue); } #endif - if(_resetTimerAfterFinish){ - [self reset]; - } }