현재 ShinobiCharts를 실험하고 있으며이를 수행 할 새 프로젝트를 만들었습니다.사용자 지정 데이터 원본 개체가 올바르게 생성되지 않습니다.
나는 데이터 소스 프로토콜을 준수하는 사용자 정의 initialiser와 객체가 있습니다
let data: [Double] = [0, 0, 0, 0, 0, 0, 10, 10, 30, 50, 100, 100, 80, 40, 30, 50, 40, 70, 20, 10, 10, 10, 0, 0]
...
let dataSource = DayGraphDataSource(data: data)
chart.datasource = dataSource
: 다음 차트의 데이터 원본으로이 개체의 인스턴스를 할당
import ShinobiCharts
import UIKit
class GraphDataSource: NSObject, SChartDatasource {
let data: [Double]
/* Initialisation Methods */
init(data: [Double]) {
self.data = data
}
/* SChartDatasource Methods */
func numberOfSeries(in chart: ShinobiChart) -> Int {
return 1
}
func sChart(_ chart: ShinobiChart, seriesAt index: Int) -> SChartSeries {
return SChartColumnSeries()
}
func sChart(_ chart: ShinobiChart, numberOfDataPointsForSeriesAt seriesIndex: Int) -> Int {
return data.count
}
func sChart(_ chart: ShinobiChart, dataPointAt dataIndex: Int, forSeriesAt seriesIndex: Int) -> SChartData {
return dataPoint(forDataIndex: dataIndex)
}
func dataPoint(forDataIndex dataIndex: Int) -> SChartData {
return SChartDataPoint(xValue: dataIndex, yValue: data[dataIndex])
}
}
을 그러나 이것은 -[<classname> numberOfSeriesInSChart:]: unrecognized selector sent to instance
이라고 불평하는 응용 프로그램을 중단시킵니다. <classname>
은 겉보기에는 모든 클래스 이름이 될 수 있습니다. 나는 다른 사람들 중에 __NSCFNumber
과 NSISRestrictedToZeroMarkerVariable
으로 보았습니다. 앱을 새로 설치하면 바뀌는 것 같습니다.
그러나 실제로 차트의 데이터 소스를이 사용자 지정 개체로 설정하고 만든 인스턴스를 인쇄하고 실행을 계속하는 중단 점을 넣으면 응용 프로그램이 제대로 실행됩니다.
정확히 동일한 데이터 소스 구현으로 뷰 컨트롤러 자체를 데이터 소스로 사용하면 모든 것이 예상대로 작동했습니다.
티켓입니다. - 감사합니다! –