From e39863c56db534daedee271d0749de5044b54e49 Mon Sep 17 00:00:00 2001 From: MartienB Date: Sun, 10 Jan 2016 22:19:33 +0100 Subject: [PATCH] Fixed memoryleaks in drawRect: method, also fixed typo's in example project. --- SHPieChartView/SHPieChartView/SHPieChartView.m | 3 +++ SHPieChartView/SHRootViewController.m | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/SHPieChartView/SHPieChartView/SHPieChartView.m b/SHPieChartView/SHPieChartView/SHPieChartView.m index 108e6a8..420506d 100644 --- a/SHPieChartView/SHPieChartView/SHPieChartView.m +++ b/SHPieChartView/SHPieChartView/SHPieChartView.m @@ -105,6 +105,7 @@ - (void)drawRect:(CGRect)rect if(_chartBackgroundColor) { CGMutablePathRef path = createArc(_center, _radius, ANGLE(0), ANGLE(360)); createAndFillArc(context, path, _chartBackgroundColor.CGColor); + CGPathRelease(path); } __block CGFloat startAngle = 0; @@ -120,6 +121,7 @@ - (void)drawRect:(CGRect)rect CGMutablePathRef path = createArc(_center, _radius, ANGLE(startAngle), ANGLE(endAngle)); createAndFillArc(context, path, color); + CGPathRelease(path); startAngle += angleValue; }]; @@ -128,6 +130,7 @@ - (void)drawRect:(CGRect)rect if(_isConcentric && _concentricRadius > 0 && _concentricColor) { CGMutablePathRef path = createArc(_center, _concentricRadius, ANGLE(0), ANGLE(360)); createAndFillArc(context, path, _concentricColor.CGColor); + CGPathRelease(path); } } diff --git a/SHPieChartView/SHRootViewController.m b/SHPieChartView/SHRootViewController.m index c8928e1..56a1d49 100644 --- a/SHPieChartView/SHRootViewController.m +++ b/SHPieChartView/SHRootViewController.m @@ -54,22 +54,22 @@ - (void)viewDidLoad concentricPieChart.concentricRadius = 70; concentricPieChart.concentricColor = UIColorFromRGB(0x54525C); - [concentricPieChart addAngleValue:0.40 andClolor:[UIColor redColor]]; + [concentricPieChart addAngleValue:0.40 andColor:[UIColor redColor]]; [self.view addSubview:concentricPieChart]; SHPieChartView *normalPieChart = [[SHPieChartView alloc] initWithFrame:CGRectMake(10, 230, 150, 150)]; - [normalPieChart addAngleValue:0.40 andClolor:[UIColor redColor]]; - [normalPieChart addAngleValue:0.20 andClolor:[UIColor greenColor]]; - [normalPieChart addAngleValue:0.30 andClolor:[UIColor blueColor]]; - [normalPieChart addAngleValue:0.10 andClolor:[UIColor orangeColor]]; + [normalPieChart addAngleValue:0.40 andColor:[UIColor redColor]]; + [normalPieChart addAngleValue:0.20 andColor:[UIColor greenColor]]; + [normalPieChart addAngleValue:0.30 andColor:[UIColor blueColor]]; + [normalPieChart addAngleValue:0.10 andColor:[UIColor orangeColor]]; [self.view addSubview:normalPieChart]; SHPieChartView *halfChart = [[SHPieChartView alloc] initWithFrame:CGRectMake(10, 400, 100, 100)]; - [halfChart addAngleValue:0.40 andClolor:UIColorFromRGB(0x3C60A3)]; + [halfChart addAngleValue:0.40 andColor:UIColorFromRGB(0x3C60A3)]; [self.view addSubview:halfChart];