DEV Community

Discussion on: How to make a task list using SwiftUI and Core Data

Collapse
 
bobmcnerney profile image
bobmcnerney

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:

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!

Collapse
 
maeganwilson_ profile image
Maegan Wilson

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.