I was trouble in 2 weeks, so please let me ask question.
Situation
XCode 7.2 Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81) https://github.com/yosuke1985/ios-charts
iOS Chart ttps://github.com/danielgindi/ios-charts
This code is from
ttp://www.appcoda.com/ios-charts-api-tutorial/
What I want
I want to use this framework, but error is EXEC_BAC_ACCESS,
I only put the window object on Viewcontroller by StoryBoard, and connect as BarChartView Class.
And wanna show Bar Chart, When I change the attribute, "noDataText" and "noDataTextDescription" It doesnt work, and cannot figure out the error comes from.
barChartView.noDataText = "there is no data"
barChartView.noDataTextDescription = "give me the reason"
Only these code doesn't work so, I start to think the problem is comes from version of Swift or XCode? Please give me advice to solve this problem.
error
EXEC_BAC_ACCESS ERROR, Screen Shot
import UIKit
import Charts
class ViewController: UIViewController {
var months: [String]!
@IBOutlet weak var barChartView: BarChartView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
barChartView.noDataText = "there is no data"
barChartView.noDataTextDescription = "give me the reason"
self.months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]
setChart(months, values: unitsSold)
}
func setChart(dataPoints: [String], values: [Double]) {
barChartView.noDataText = "You need to provide data for the chart."
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
let chartData = BarChartData(xVals: months, dataSet: chartDataSet)
barChartView.data = chartData
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}