I have the following code:
class ChartSeriesRow: ObservableObject {
var id = UUID()
var chartCategory: String
struct ChartSeriesData {
var chartEntry: [ChartData]
}
var chartSeries : ChartSeriesData
struct ChartData: Codable, Identifiable, Hashable {
var id = UUID()
let chartMonth: String
let chartSales: String
}
init() {
chartCategory = ""
chartSeries = ChartSeriesData(chartEntry: [ChartData(chartMonth: "01", chartSales: "10.0") ] )
}
}
How do I populate ChartSeriesData? I thought I could just add the following: However coding this way there is no append method.
extension ChartSeriesRow {
func addRow(chartRow: ChartSeriesData){
ChartSeriesRow.ChartSeriesData.chartEntry.append(contentsOf: chartRow)
}
}