Merge pull request #51 from rochefort/modern-syntax
Convert to modern Objective-C syntax
Showing
6 changed files
with
16 additions
and
16 deletions
| @@ -59,8 +59,8 @@ | @@ -59,8 +59,8 @@ | ||
| 59 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 59 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 60 | pathAnimation.duration = 1.0; | 60 | pathAnimation.duration = 1.0; |
| 61 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 61 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 62 | - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 62 | + pathAnimation.fromValue = @0.0f; |
| 63 | - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 63 | + pathAnimation.toValue = @1.0f; |
| 64 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 64 | [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 65 | 65 | ||
| 66 | _chartLine.strokeEnd = 1.0; | 66 | _chartLine.strokeEnd = 1.0; |
| @@ -244,8 +244,8 @@ | @@ -244,8 +244,8 @@ | ||
| 244 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 244 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 245 | pathAnimation.duration = 0.5; | 245 | pathAnimation.duration = 0.5; |
| 246 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 246 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 247 | - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 247 | + pathAnimation.fromValue = @0.0f; |
| 248 | - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 248 | + pathAnimation.toValue = @1.0f; |
| 249 | [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 249 | [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 250 | 250 | ||
| 251 | _chartBottomLine.strokeEnd = 1.0; | 251 | _chartBottomLine.strokeEnd = 1.0; |
| @@ -276,8 +276,8 @@ | @@ -276,8 +276,8 @@ | ||
| 276 | CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 276 | CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 277 | pathLeftAnimation.duration = 0.5; | 277 | pathLeftAnimation.duration = 0.5; |
| 278 | pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 278 | pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 279 | - pathLeftAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 279 | + pathLeftAnimation.fromValue = @0.0f; |
| 280 | - pathLeftAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 280 | + pathLeftAnimation.toValue = @1.0f; |
| 281 | [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"]; | 281 | [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"]; |
| 282 | 282 | ||
| 283 | _chartLeftLine.strokeEnd = 1.0; | 283 | _chartLeftLine.strokeEnd = 1.0; |
| @@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
| 40 | CGFloat startAngle = clockwise ? -90.0f : 270.0f; | 40 | CGFloat startAngle = clockwise ? -90.0f : 270.0f; |
| 41 | CGFloat endAngle = clockwise ? -90.01f : 270.01f; | 41 | CGFloat endAngle = clockwise ? -90.01f : 270.01f; |
| 42 | 42 | ||
| 43 | - _lineWidth = [NSNumber numberWithFloat:8.0]; | 43 | + _lineWidth = @8.0f; |
| 44 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x, self.center.y) radius:self.frame.size.height * 0.5 startAngle:DEGREES_TO_RADIANS(startAngle) endAngle:DEGREES_TO_RADIANS(endAngle) clockwise:clockwise]; | 44 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x, self.center.y) radius:self.frame.size.height * 0.5 startAngle:DEGREES_TO_RADIANS(startAngle) endAngle:DEGREES_TO_RADIANS(endAngle) clockwise:clockwise]; |
| 45 | 45 | ||
| 46 | _circle = [CAShapeLayer layer]; | 46 | _circle = [CAShapeLayer layer]; |
| @@ -94,8 +94,8 @@ | @@ -94,8 +94,8 @@ | ||
| 94 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 94 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 95 | pathAnimation.duration = 1.0; | 95 | pathAnimation.duration = 1.0; |
| 96 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 96 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 97 | - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 97 | + pathAnimation.fromValue = @0.0f; |
| 98 | - pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue] / [_total floatValue]]; | 98 | + pathAnimation.toValue = @([_current floatValue] / [_total floatValue]); |
| 99 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 99 | [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 100 | _circle.strokeEnd = [_current floatValue] / [_total floatValue]; | 100 | _circle.strokeEnd = [_current floatValue] / [_total floatValue]; |
| 101 | 101 |
| @@ -238,8 +238,8 @@ | @@ -238,8 +238,8 @@ | ||
| 238 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 238 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; |
| 239 | pathAnimation.duration = 1.0; | 239 | pathAnimation.duration = 1.0; |
| 240 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | 240 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
| 241 | - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; | 241 | + pathAnimation.fromValue = @0.0f; |
| 242 | - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; | 242 | + pathAnimation.toValue = @1.0f; |
| 243 | [chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | 243 | [chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; |
| 244 | 244 | ||
| 245 | chartLine.strokeEnd = 1.0; | 245 | chartLine.strokeEnd = 1.0; |
| @@ -70,7 +70,7 @@ | @@ -70,7 +70,7 @@ | ||
| 70 | data01.color = PNFreshGreen; | 70 | data01.color = PNFreshGreen; |
| 71 | data01.itemCount = lineChart.xLabels.count; | 71 | data01.itemCount = lineChart.xLabels.count; |
| 72 | data01.getData = ^(NSUInteger index) { | 72 | data01.getData = ^(NSUInteger index) { |
| 73 | - CGFloat yValue = [[data01Array objectAtIndex:index] floatValue]; | 73 | + CGFloat yValue = [data01Array[index] floatValue]; |
| 74 | return [PNLineChartDataItem dataItemWithY:yValue]; | 74 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| @@ -80,7 +80,7 @@ | @@ -80,7 +80,7 @@ | ||
| 80 | data02.color = PNTwitterColor; | 80 | data02.color = PNTwitterColor; |
| 81 | data02.itemCount = lineChart.xLabels.count; | 81 | data02.itemCount = lineChart.xLabels.count; |
| 82 | data02.getData = ^(NSUInteger index) { | 82 | data02.getData = ^(NSUInteger index) { |
| 83 | - CGFloat yValue = [[data02Array objectAtIndex:index] floatValue]; | 83 | + CGFloat yValue = [data02Array[index] floatValue]; |
| 84 | return [PNLineChartDataItem dataItemWithY:yValue]; | 84 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| @@ -135,7 +135,7 @@ | @@ -135,7 +135,7 @@ | ||
| 135 | circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; | 135 | circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; |
| 136 | circleChartLabel.textAlignment = NSTextAlignmentCenter; | 136 | circleChartLabel.textAlignment = NSTextAlignmentCenter; |
| 137 | 137 | ||
| 138 | - PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:YES andShadow:YES]; | 138 | + PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:@100 andCurrent:@60 andClockwise:YES andShadow:YES]; |
| 139 | circleChart.backgroundColor = [UIColor clearColor]; | 139 | circleChart.backgroundColor = [UIColor clearColor]; |
| 140 | [circleChart setStrokeColor:PNGreen]; | 140 | [circleChart setStrokeColor:PNGreen]; |
| 141 | [circleChart strokeChart]; | 141 | [circleChart strokeChart]; |
| @@ -49,7 +49,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | @@ -49,7 +49,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | ||
| 49 | data01.color = PNFreshGreen; | 49 | data01.color = PNFreshGreen; |
| 50 | data01.itemCount = lineChart.xLabels.count; | 50 | data01.itemCount = lineChart.xLabels.count; |
| 51 | data01.getData = ^(NSUInteger index) { | 51 | data01.getData = ^(NSUInteger index) { |
| 52 | - CGFloat yValue = [[data01Array objectAtIndex:index] floatValue]; | 52 | + CGFloat yValue = [data01Array[index] floatValue]; |
| 53 | return [PNLineChartDataItem dataItemWithY:yValue]; | 53 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 54 | }; | 54 | }; |
| 55 | // Line Chart No.2 | 55 | // Line Chart No.2 |
| @@ -58,7 +58,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | @@ -58,7 +58,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | ||
| 58 | data02.color = PNTwitterColor; | 58 | data02.color = PNTwitterColor; |
| 59 | data02.itemCount = lineChart.xLabels.count; | 59 | data02.itemCount = lineChart.xLabels.count; |
| 60 | data02.getData = ^(NSUInteger index) { | 60 | data02.getData = ^(NSUInteger index) { |
| 61 | - CGFloat yValue = [[data02Array objectAtIndex:index] floatValue]; | 61 | + CGFloat yValue = [data02Array[index] floatValue]; |
| 62 | return [PNLineChartDataItem dataItemWithY:yValue]; | 62 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 63 | }; | 63 | }; |
| 64 | 64 |
-
Please register or login to post a comment