【发布时间】:2020-05-14 17:36:28
【问题描述】:
我正在尝试在 SwiftUI 中使用 ForEach,而我的 NSOrderedSet 来自 FetchedResult。 已经尝试过以下代码(来自response)
withChilds 是定义的关系(核心数据 - 一张卡片有很多孩子)。
卡内:
@NSManaged public var withChilds: NSOrderedSet?
我的查看代码
struct Test: View {
@FetchRequest(entity: Card.entity(),
sortDescriptors: [],
predicate: nil)
var cards: FetchedResults<Card>
var body: some View {
VStack {
Text("count: \(cards[0].withChilds?.count)") //first entity on purpose
ScrollView {
ForEach(cards){ card in
ForEach(Array(card.withChilds!.set), id: \.self) { child in //**ERROR**
//Text("someText: \(child.text1)")
}
}
}
}
}
}
【问题讨论】:
标签: swift core-data swiftui nsorderedset