Recall & Review
beginner
What does CRUD stand for in app development?
CRUD stands for Create, Read, Update, and Delete. These are the four basic operations to manage data in an app.
Click to reveal answer
beginner
How do you create a new object in SwiftData?
You create a new object by initializing your model and then saving the context. For example, use @Model to define data and then call context.insert(newObject) followed by context.save().
Click to reveal answer
beginner
How do you fetch data using SwiftData?
Use a @Query property wrapper to fetch data. It automatically keeps your UI updated when data changes. For example, @Query var items: [Item] fetches all Item objects.
Click to reveal answer
intermediate
How do you update an existing object in SwiftData?
To update, change the properties of the fetched object and then save the context. SwiftData tracks changes automatically, so just call context.save() after editing.
Click to reveal answer
beginner
What is the correct way to delete an object in SwiftData?
Call context.delete(object) on the object you want to remove, then save the context with context.save(). This removes the object from the database.
Click to reveal answer
Which SwiftData property wrapper is used to fetch data reactively?
✗ Incorrect
@Query fetches data from SwiftData and updates the UI automatically when data changes.
What must you do after creating or modifying data in SwiftData to save changes?
✗ Incorrect
You must call context.save() to persist changes to the database.
How do you delete an object from SwiftData?
✗ Incorrect
Deleting requires calling context.delete(object) and then saving the context.
Which CRUD operation involves changing properties of an existing object?
✗ Incorrect
Update means modifying existing data.
What is the purpose of the @Model attribute in SwiftData?
✗ Incorrect
@Model marks a class or struct as a data model for SwiftData.
Explain the steps to create and save a new data object using SwiftData.
Think about how you add a new item to a list and save it.
You got /4 concepts.
Describe how SwiftData helps keep your app UI updated when data changes.
Imagine your app list changes automatically when you add or remove items.
You got /3 concepts.