0PricingLogin
SwiftUI Academy · Lesson

Defining @Model Types

Annotate classes as persistent models.

Meet SwiftData

SwiftData is Apple's modern way to save app data right on the device. You describe your data once, and it handles storage for you. 💾

The @Model Macro

You turn a plain class into a saved type by adding the @Model macro above it. That one line makes every instance persistable.

@Model
class Task {
}

All lessons in this course

  1. Defining @Model Types
  2. The Model Container & Context
  3. Querying with @Query
  4. Inserting, Updating & Deleting
← Back to SwiftUI Academy