Inserting, Updating & Deleting
Mutate the store and reflect changes live.
Changing Your Data
Now you will change the store: add new records, edit existing ones, and remove what you no longer need. ✏️
Inserting a Record
Create an object and call insert on the context to add it. SwiftData starts tracking it for saving right away.
let task = Task(title: "Walk dog")
context.insert(task)All lessons in this course
- Defining @Model Types
- The Model Container & Context
- Querying with @Query
- Inserting, Updating & Deleting