0PricingLogin
SwiftUI Academy · Lesson

Querying with @Query

Fetch and sort persisted data in views.

Fetching Saved Data

To show stored records in a view, you fetch them with @Query. It reads from your container and keeps the view fresh. 🔍

The @Query Property

Declare an array property with @Query and SwiftData fills it with every matching record. No manual loading needed.

@Query private var tasks: [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