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)")
}
}
}
}
}
}

The highlighted error is because there is no view specified in
ForEach, so if to define something static, likethere should be no error (tested with Xcode 11.4)
But there is no specified what is inside that
NSOrderedSet, so if suppose it is instances ofChildclass then the following tested works