From 4855d5c887c3420e0bc8609018bfa814710f1619 Mon Sep 17 00:00:00 2001 From: Obada Date: Sun, 11 Oct 2020 09:53:58 +0300 Subject: [PATCH] Added a check to avoid crashing if the precentage is 0 - I ran into this crash when receiving a 0 value from the backend server and the app attmepted to draw a chart for it. This way we'll avoid the crash vy not drawing the chart if the model.value property is 0 --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ PieCharts/Core/Chart/PieChart.swift | 1 + 2 files changed, 9 insertions(+) create mode 100644 PieCharts.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/PieCharts.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PieCharts.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PieCharts.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/PieCharts/Core/Chart/PieChart.swift b/PieCharts/Core/Chart/PieChart.swift index ed13c18..50f53ec 100644 --- a/PieCharts/Core/Chart/PieChart.swift +++ b/PieCharts/Core/Chart/PieChart.swift @@ -161,6 +161,7 @@ import UIKit public func insertSlice(index: Int, model: PieSliceModel) { guard index < slices.count else {print("Out of bounds index: \(index), slices count: \(slices.count), exit"); return} + guard model.value != 0 else {print("Cannot divide by 0 at index: \(index), exit"); return} for layer in layers { layer.clear()