Reputation: 463
I have a problem where the master pane list view rows are not updating correctly in an iPad. I have reduced the code for description purposes to
struct CarsList : View {
@State var isPresented = false
@FetchRequest(fetchRequest: Car.allCarsFetchRequest())
var cars: FetchedResults<Car>
var body: some View {
NavigationView {
List {
Button("Add Car") {
self.isPresented.toggle()
}
ForEach (self.cars) { car in
VStack {
Text ("List Car name: \(car.name!)")
NavigationLink(destination: CarDetailView(carVM: CarViewModel(car: car)) ) {
CarRowView(car: car)
}
}
}
}
}
.sheet(isPresented: $isPresented, onDismiss: { }, content: {
CarDetailView(carVM: CarViewModel())
})
}
}
The iPad left pane shows a list of car names (CoreData managed objects). For test purposes, I show the name twice - in the Text(“List car name…“) and below the name is shown again in the CarRowView. The CarRowView has car: Car declared as an ObservedObject. I can tap on a row, to go to a detail view, where I can change the car name. When I do so, the List updates in that the Text(“List car name…“) shows the new name, but the CarRowView does not change. So changing the "car" in the detail pane, immediately shows in the List (in Text("List car name..") ) and yet even though that car object is sent to the CarRowView, where it is an ObservedObject, the CarRowView display does not change. The app uses CloudKit, and after I make the change, the new name appears ok on an iPhone (in CarRowView) running the same code. Any ideas why CarRowView would not update on the master pane of the iPad?
Upvotes: 0
Views: 375
Reputation: 463
It looks like this was a SwiftUI bug and not a problem with the code as it now works with 13.3.
Upvotes: 1