ios_catalogue1-6 Exercise 3: Binding Straight to the Model =========================================================== The test form: struct DirectEditView: View { @Bindable var item: Item @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { Form { TextField("Title", text: $item.title) } .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Cancel") { dismiss() } } } } } } What to record, each time, and what it means: 1. Edit the title, press Cancel, look at the list: the list almost certainly shows the NEW title. A Cancel that only dismisses cannot undo an edit that was applied to the live object on every keystroke. (This part is certain from how bindings work; it is not a SwiftData peculiarity.) 2. Quit the app (swipe it away) and relaunch: is the new title still there? That depends on whether the context autosaved after the edit. Apple's documentation says autosave is a setting, and forum threads describe it as not guaranteed in either direction, so write down what YOUR setup does. If the edit persisted, Cancel did not cancel at all; if it did not persist, the app showed one thing and stored another until relaunch: also bad. 3. Also try: edit, then press Cancel, then immediately open another screen that reads the title. It shows the edited text even though the user "cancelled". Conclusion: whichever the outcome in step 2, step 1 already shows why a form with Cancel should edit a COPY. The draft struct makes the behaviour deterministic: the model is untouched until Save. Alternatives found in the sources, for comparison: (a) a separate ModelContext used only by the sheet, discarded on Cancel ("sandboxing"), which keeps the convenience of bindings but needs care with two contexts; (b) calling rollback on the context on Cancel, which also discards other unsaved work in that context. The draft struct avoids both complications at the cost of copying the fields.