hi,
i am assuming that you are describing this problem: you tap the Add button inTaskItemsView
the addTask() function does indeed add a new Task to the list (var list: TaskList)
the TaskItemsView does not update
if that's the case, in TaskItemsView, you should do two things: define the list variable as @ObservedObject var list: TaskList. this makes the TaskItemsView responsive to changes in Core Data attributes of the list.
after line 43 (list.addToItems(newTask)) add list.objectWillChange.send(). adding a new TaskItem to the list's NSSet of TaskItems is not seen as a change to a list attribute (its reference to the NSSet), so you need to signal a change to the list yourself.
hope that helps,
DMG
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: