What is the best / most efficient way to access core data children in a multilevel one-to-many model?
I have a model with Board > List > Card > ..., always in a one-to-many relation. At the start view all Boards are fetched.
Let's say we are in the SingleListView, looking at all cards from one List, that has been passed in. Now I can either directly use the Core Data class accessor from the list (NSSet transformed to Array):
@ObservedObject var list: ListEntity
...
ForEach(list.cardsArray) {
....
or I can fetch the cards with predicate
@FetchRequest
private var cards: FetchedResults<CardEntity>
init(list: ListEntity) {
_cards = FetchRequest<CardEntity>(
sortDescriptors: [ ... ],
predicate: NSPredicate(format: "ofList == %@", list),
animation: .default)
}
Is any of these better, more appropriate, more efficient towards view updates ... ?
Especially when I go deeper into the tree structure, it feels strange that all is relying on one first FetchRequest up the chain.