Exercise 3: Why Sharing One TaskStore Instance Keeps All Three Screens in Sync — Possible Solution ========================================================================================================== Per Chapter 4, the fundamental difference between a struct (value type) and a class (reference type) is what happens when a value is assigned or passed around: a struct is genuinely COPIED, producing a fully independent instance, while a class is genuinely SHARED - every variable holding it points at the exact same single underlying instance in memory, with no copying involved at all. TaskStore is deliberately declared as a class (marked @Observable), not a struct. This means when TaskListView, TaskDetailView, and NewTaskView are each handed store, none of them receive their own separate copy of the task data - all three genuinely hold a reference to the identical single TaskStore instance created once in TaskFlowApp. There is only ever one real tasks array in the entire running app, not three independent, potentially-diverging ones. This is precisely why calling store.toggleDone(for: task) inside TaskDetailView has an effect visible back in TaskListView: both views are looking at the SAME underlying tasks array, not two separate copies that happened to start out looking similar. If TaskStore had instead been a struct (a value type), each view receiving it would have gotten its own independent copy the moment it was passed in - per Chapter 4's own Rectangle/Point examples, mutating one view's own copy would have left every other view's copy completely unaffected, exactly like Exercise 1 of Chapter 4 demonstrated with a scaled rectangle leaving the original untouched. ANSWER: TaskStore is a class (a reference type, per Chapter 4), so passing it to TaskListView, TaskDetailView, and NewTaskView shares the exact same single instance across all three rather than copying it - there is only ever one real tasks array in the whole app. This is why toggling a task's done state in one screen is instantly visible in another: they're all looking at identical shared state, not independent copies that could diverge the way three copies of a value type would. WHY THIS WORKS AS AN ANSWER ------------------------------ This directly ties the capstone's own cross-screen sync behavior back to Chapter 4's value-type/reference-type distinction, explaining concretely what would break (independent, diverging copies) had TaskStore been declared as a struct instead of a class.