From 545eafb194a31a44a6dc6bafe78678ca838d5bea Mon Sep 17 00:00:00 2001 From: rochefort Date: Sat, 3 May 2014 00:14:45 +0900 Subject: [PATCH] Convert to modern Objective-C syntax --- PNChart/PNBarChart/PNBar.m | 4 ++-- PNChart/PNBarChart/PNBarChart.m | 8 ++++---- PNChart/PNCircleChart/PNCircleChart.m | 6 +++--- PNChart/PNLineChart/PNLineChart.m | 4 ++-- PNChartDemo/PCChartsTableViewController.m | 6 +++--- README.md | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/PNChart/PNBarChart/PNBar.m b/PNChart/PNBarChart/PNBar.m index c6a61505..f92b6553 100644 --- a/PNChart/PNBarChart/PNBar.m +++ b/PNChart/PNBarChart/PNBar.m @@ -59,8 +59,8 @@ - (void)setGrade:(float)grade CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation.duration = 1.0; pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; + pathAnimation.fromValue = @0.0f; + pathAnimation.toValue = @1.0f; [_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; _chartLine.strokeEnd = 1.0; diff --git a/PNChart/PNBarChart/PNBarChart.m b/PNChart/PNBarChart/PNBarChart.m index 90b5566b..7d626604 100644 --- a/PNChart/PNBarChart/PNBarChart.m +++ b/PNChart/PNBarChart/PNBarChart.m @@ -244,8 +244,8 @@ - (void)strokeChart CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation.duration = 0.5; pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; + pathAnimation.fromValue = @0.0f; + pathAnimation.toValue = @1.0f; [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; _chartBottomLine.strokeEnd = 1.0; @@ -276,8 +276,8 @@ - (void)strokeChart CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathLeftAnimation.duration = 0.5; pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - pathLeftAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; - pathLeftAnimation.toValue = [NSNumber numberWithFloat:1.0f]; + pathLeftAnimation.fromValue = @0.0f; + pathLeftAnimation.toValue = @1.0f; [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"]; _chartLeftLine.strokeEnd = 1.0; diff --git a/PNChart/PNCircleChart/PNCircleChart.m b/PNChart/PNCircleChart/PNCircleChart.m index b2310e4a..d9f59f72 100644 --- a/PNChart/PNCircleChart/PNCircleChart.m +++ b/PNChart/PNCircleChart/PNCircleChart.m @@ -40,7 +40,7 @@ - (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumbe CGFloat startAngle = clockwise ? -90.0f : 270.0f; CGFloat endAngle = clockwise ? -90.01f : 270.01f; - _lineWidth = [NSNumber numberWithFloat:8.0]; + _lineWidth = @8.0f; 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]; _circle = [CAShapeLayer layer]; @@ -94,8 +94,8 @@ - (void)strokeChart CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation.duration = 1.0; pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; - pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue] / [_total floatValue]]; + pathAnimation.fromValue = @0.0f; + pathAnimation.toValue = @([_current floatValue] / [_total floatValue]); [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; _circle.strokeEnd = [_current floatValue] / [_total floatValue]; diff --git a/PNChart/PNLineChart/PNLineChart.m b/PNChart/PNLineChart/PNLineChart.m index 06942d21..1772c959 100644 --- a/PNChart/PNLineChart/PNLineChart.m +++ b/PNChart/PNLineChart/PNLineChart.m @@ -238,8 +238,8 @@ - (void)strokeChart CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation.duration = 1.0; pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; - pathAnimation.toValue = [NSNumber numberWithFloat:1.0f]; + pathAnimation.fromValue = @0.0f; + pathAnimation.toValue = @1.0f; [chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; chartLine.strokeEnd = 1.0; diff --git a/PNChartDemo/PCChartsTableViewController.m b/PNChartDemo/PCChartsTableViewController.m index af46b486..1521dc58 100644 --- a/PNChartDemo/PCChartsTableViewController.m +++ b/PNChartDemo/PCChartsTableViewController.m @@ -70,7 +70,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender data01.color = PNFreshGreen; data01.itemCount = lineChart.xLabels.count; data01.getData = ^(NSUInteger index) { - CGFloat yValue = [[data01Array objectAtIndex:index] floatValue]; + CGFloat yValue = [data01Array[index] floatValue]; return [PNLineChartDataItem dataItemWithY:yValue]; }; @@ -80,7 +80,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender data02.color = PNTwitterColor; data02.itemCount = lineChart.xLabels.count; data02.getData = ^(NSUInteger index) { - CGFloat yValue = [[data02Array objectAtIndex:index] floatValue]; + CGFloat yValue = [data02Array[index] floatValue]; return [PNLineChartDataItem dataItemWithY:yValue]; }; @@ -135,7 +135,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender circleChartLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:23.0]; circleChartLabel.textAlignment = NSTextAlignmentCenter; - 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]; + PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:@100 andCurrent:@60 andClockwise:YES andShadow:YES]; circleChart.backgroundColor = [UIColor clearColor]; [circleChart setStrokeColor:PNGreen]; [circleChart strokeChart]; diff --git a/README.md b/README.md index ecd71bf9..1cc915c4 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ You will need LLVM 3.0 or later in order to build PNChart. data01.color = PNFreshGreen; data01.itemCount = lineChart.xLabels.count; data01.getData = ^(NSUInteger index) { - CGFloat yValue = [[data01Array objectAtIndex:index] floatValue]; + CGFloat yValue = [data01Array[index] floatValue]; return [PNLineChartDataItem dataItemWithY:yValue]; }; // Line Chart No.2 @@ -58,7 +58,7 @@ You will need LLVM 3.0 or later in order to build PNChart. data02.color = PNTwitterColor; data02.itemCount = lineChart.xLabels.count; data02.getData = ^(NSUInteger index) { - CGFloat yValue = [[data02Array objectAtIndex:index] floatValue]; + CGFloat yValue = [data02Array[index] floatValue]; return [PNLineChartDataItem dataItemWithY:yValue]; };