【发布时间】:2019-01-16 06:01:43
【问题描述】:
我有一个名为“供品”的供品数组。我已经对数组进行了分组,如下所示。
let groupedBonds = Dictionary(grouping: data.offerings) { (Offering) -> String in
return Offering.company
}
public struct Offering: Codable {
public let company: String
public let amount: Int
public let location: String
}
字典的键是companies -> ["ABCD", "EFGH", "IJKL", "MNOP"]
我想汇总各个公司的所有金额。请帮助我实现这个结果。
【问题讨论】:
标签: ios arrays swift dictionary struct