【发布时间】:2019-07-31 12:57:46
【问题描述】:
1) 我想显示来自多个数组的数据(数据是相同的,只是分成不同的数组)。我该怎么做?
2) 我只想显示整个数组中的特定选择。
我在这些数组中创建了一种 ID 形式,称为“groupid: Int”,它出现在数组中。在这种情况下,我想从多个数组中提取所有带有“groupid:1”的条目并将它们显示在一个列表中。
// 我要在其中显示最终列表的视图:
import SwiftUI
struct French1View : View {
var body: some View {
NavigationView {
List {
ForEach(XXXXX????) { grape in
GrapeCell(grape: grape)
}
.navigationBarTitle("French wine grapes")
}
}
}
}
// 数组:
let BGrapes = [
Grape(id: 1,
groupid: 1,
name: "Barbera",
type: "White"),
Grape(id: 2,
groupid: 2,
name: "Bosco",
type: "Red")
]
let CGrapes = [
Grape(id: 1,
groupid: 1,
name: "Barbera",
type: "White")
]
正如您在代码中看到的那样,我被困在我应该输入的内容上(对于这个例子)我写了“XXXXX????”
我试过写“(BGrapes, CGrapes) && grape.groupid(1)”但没有成功。
【问题讨论】: