It helped me, a SwiftUI beginner, a great deal. But when I tried to build up I definitely got stumped.
I have a need for similar functionality but with the need to update a text field such as "name" rather than the Boolean "isComplete". I changed your code to update the "name" field from a constant:
taskUpdate.setValue("testJohn", forKey: "name")
This did not update CoreData. But, If when I added the following after the .setValue, core data is updated.
try context.save()
However, the tab view is not updated until I close and re-open the app.
Any assistance that you can provide will be immensely helpful!
I’ve run into this issue myself. I solved this by using an environment object that stores an array of the objects. It’s probably a bit of a performance hit, but it was a work around. I do mean to look into it at some point though. I’m sorry that I couldn’t be more help.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the helpful post Maegan!
It helped me, a SwiftUI beginner, a great deal. But when I tried to build up I definitely got stumped.
I have a need for similar functionality but with the need to update a text field such as "name" rather than the Boolean "isComplete". I changed your code to update the "name" field from a constant:
This did not update CoreData. But, If when I added the following after the .setValue, core data is updated.
However, the tab view is not updated until I close and re-open the app.
Any assistance that you can provide will be immensely helpful!
I’ve run into this issue myself. I solved this by using an environment object that stores an array of the objects. It’s probably a bit of a performance hit, but it was a work around. I do mean to look into it at some point though. I’m sorry that I couldn’t be more help.