When I try to use this solution in Xcode 11 Beta 4, I receive an error with this code:
List(store.items, id:\.objectID) { item in
NavigationLink(destination: Detail(item: item)) {
Row(item: item)
}
}.onAppear {
self.store.performFetch()
}
"UITableView was told to layout its visible cells and other contents without being in the view hierarchy. ..." and
"Invalid update: invalid number of sections. ..."
However, changing the code to add a 0.1s delay before fetching fixes the issue:
List(store.items, id:\.objectID) { item in
NavigationLink(destination: Detail(item: item)) {
Row(item: item)
}
}.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.store.performFetch()
}
}
I only have about 10 items in my store so the time for the fetch is very small. Could it be that your 50000 row fetch takes more than my 1ms delay so you don't experience this problem? Is there a better way to execute the fetch than "onAppear".