ios_catalogue1-2 Exercise 2: Objects and Deletes ================================================= Stored objects (SwiftData keeps the relationships; there are no ids or link rows for you to see): ItemType "Book" items: [Dune] ItemType "CD" items: [] ItemType "DVD" items: [Alien] ItemType "Blu-ray" items: [] Item "Dune" type: Book tags: [sci-fi, classic] Item "Alien" type: DVD tags: [sci-fi] Tag "sci-fi" items: [Dune, Alien] Tag "classic" items: [Dune] (The relationship arrays are two views of the same links: setting dune.tags also updates the tags' items when the inverse is declared correctly.) Delete the tag "sci-fi" (default nullify): - the Tag object is removed; it disappears from Dune.tags and Alien.tags. - Dune keeps "classic"; Alien is left with no tags. Both items remain. Delete "Dune": - the Item is removed; it disappears from sci-fi.items and classic.items. - the tags remain (classic is now unused, which is allowed). - ItemType Book.items no longer lists Dune. Delete the type DVD: - Alien still uses it, so with deleteRule: .deny the delete should be REFUSED (SwiftData throws an error at save time or on delete). Delete or re-type Alien first. This is the counterpart of RESTRICT in Room. - Test this when you build Chapter 3's container: the behaviour of .deny was not confirmed in my sources.