0

I'm having trouble updating my view after editing CoreData.

I have this entry in my CoreData entity named "TST" and through a NavigationLink I'm editing it's name

NavigationLink(destination: editingPage(thread: tr.title)){
Text(tr.title)}
    @State var thread : String

        Form {
            TextField("thread", text:$thread)
        }.onDisappear{
            do {
                try self.managedObjectContext.save()
            } catch {
                print(error.localizedDescription)
            }
        }

after editing and saving the MOC It doesn't display the changes until I either restart the app, or go back to the beginning of my navigation View.

Should I have a fetch request on all page displaying CoreData's data? or having some kind of ObservedObject ?

What I'm looking for is the same as changing your device's name in the device settings menu.

Thanks Tim

Tim
  • 129
  • 1
  • 8
  • This topic [How to update @FetchRequest, when a related Entity changes in SwiftUI?](https://stackoverflow.com/questions/58643094/how-to-update-fetchrequest-when-a-related-entity-changes-in-swiftui/58777603#58777603) should be helpful. Read also later comments. – Asperi Mar 19 '20 at 18:51
  • Ok thanks, I hope a better way to do it exists, it doesn’t really look Apple-like. – Tim Mar 19 '20 at 21:00

0 Answers0