Skip to content

Commit

Permalink
Update UICountingLabel.m
Browse files Browse the repository at this point in the history
If user not set value for `format` and set `startValue` 、`endValue`  、 `duration` all to 0,  it will crash when call `[self setTextValue:endValue]` . It's because the format is nil when use`[NSString stringWithFormat:self.format,(int)value]`
  • Loading branch information
GuoZhiQiang authored Dec 6, 2017
1 parent a1d8d89 commit 0ab17df
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions UICountingLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeIn
[self.timer invalidate];
self.timer = nil;

if(self.format == nil) {
self.format = @"%f";
}
if (duration == 0.0) {
// No animation
[self setTextValue:endValue];
Expand All @@ -121,9 +124,6 @@ -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeIn
self.totalTime = duration;
self.lastUpdate = [NSDate timeIntervalSinceReferenceDate];

if(self.format == nil)
self.format = @"%f";

switch(self.method)
{
case UILabelCountingMethodLinear:
Expand Down

0 comments on commit 0ab17df

Please sign in to comment.