I am trying to use ForEach in SwiftUI with my NSOrderedSet with comes from a FetchedResult. Tried already the following code (from this response)
withChilds is a relationship definied (Core Data - one Card has many childs).
In Card:
@NSManaged public var withChilds: NSOrderedSet?
My View Code
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)")
}
}
}
}
}
}