Pick the fix
A detail screen edits an item, and the list must update when it saves. Best approach?
Hint 1 of 1
How does the child talk back without knowing the parent?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A The list creates the detail with onSave: (Item) -> Void (or sets a weak delegate) and updates itself in the callback
Correct. The dependency is explicit and decoupled.
Why not the others?
- B Post a global Notification from the detail. It is untyped and global, so any object can react and flows are hard to trace.
- C
(presentingViewController as! ListViewController).update(item). It couples the screens and crashes if the hierarchy changes. - D Mutate a singleton and hope the list refreshes. Nothing tells the list to update.