In SwiftUI, I have a simple core data entity, and one of the attributes called "finished" (Bool).
I fetch the core data to create a List in ListView. When I click an item of the List, it goes to the DetailView, which includes the record "finished".
In the DetailView, I added a toggle button to SHOW the value of "finished", and meanwhile I use this toggle button to UPDATE the record of "finished" in core data.
The curent problem is I can use this toggle button to CHANGE the record in core data; however, the result CANNOT be updated immediately in DeailView. (That means, when I go back to ListView, I see it's updated. And when I click the item and go to DetailView, the record's also properly shown.)
1) How to fix this issue? What's the best way to do it?
2) What's the proper way to assign the core data value of "finished" to the toggle button, when DetailView's launched?
I'm new to Swift, and very grateful for anybody's help.