I'm trying to pass in two different structs (that inherit from the same protocol) into one struct init method but I'm getting the following error:
Cannot convert value of type '[TopContentModel]' to '[TopModel]'
Here's the code that I have:
protocol TopModel {
}
struct TopContentModel: TopModel {
var type: TableType?
var contentType: ContentType?
var title : String?
var total: Float?
}
struct TopPlatformModel: TopModel {
var platform: PlatformType?
var total: Float?
var type: TableType?
}
struct ChartInfo {
var title: String?
var type: ChartType?
var prefix: String = ""
var labels: [String]?
var values: [Float]?
var list: [TopModel]?
var formatter: NSNumberFormatter?
var special: String?
var secondSpecial: String?
var color: String?
}
var topEarningData = [TopContentModel]()
ChartInfo(title: "Top Earning Assets", type: .TopContent, prefix: "$", labels: nil, values: nil, list: topEarningData, formatter: nil, special: nil, secondSpecial: nil, color: "#37e0af")