私は現在、ShinobiChartsを実験しており、これを行うための新しいプロジェクトを作成しました。カスタムデータソースオブジェクトが正しく作成されない
Iは、データ・ソース・プロトコルに準拠したカスタム初期化子を持つオブジェクト有する:
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
のように見ました - それは、アプリケーションの新インストール時に変更されるようです。
しかし、グラフ上のデータソースを実際にこのカスタムオブジェクトに設定し、作成したインスタンスを印刷して実行を継続する行にブレークポイントを設定すると、アプリケーションは完全に正常に実行されます。
データソースとしてビューコントローラ自体を持っていて、まったく同じデータソース実装では、すべてが期待通りに機能しました。
これはチケットです - ありがとう! –