ios_catalogue1-5 Exercise 2: Swipe to Delete with Confirmation =============================================================== In ListView: @State private var itemPendingDeletion: Item? // on the row: NavigationLink(value: item) { ItemRow(item: item) } .swipeActions(edge: .trailing) { Button("Delete", systemImage: "trash", role: .destructive) { itemPendingDeletion = item } } // on the List (or VStack): .confirmationDialog( "Delete this item?", isPresented: Binding(get: { itemPendingDeletion != nil }, set: { if !$0 { itemPendingDeletion = nil } }), titleVisibility: .visible, presenting: itemPendingDeletion ) { item in Button("Delete", role: .destructive) { try? CatalogueRepository(context: context).delete(item) itemPendingDeletion = nil } Button("Cancel", role: .cancel) { itemPendingDeletion = nil } } message: { item in Text("\"\(item.title)\" will be removed from your catalogue.") } Why a Bool is not enough: there is ONE dialog but MANY rows. A single "showConfirm" flag cannot say WHICH row the user swiped. The state must record the item itself (itemPendingDeletion), and "is the dialog showing" is derived from "is there an item waiting". The dialog lives on the list, not on each row: a dialog per row would create one presentation per item and is fragile inside a lazily built List. Deleting from the list does not have the detail screen's stale-reference problem (no screen is displaying the item), but the ItemRow that showed it is removed by @Query on the next update, so the same "never read a deleted model" rule applies to anything else you keep, such as itemPendingDeletion: it is cleared right after the delete.