Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Can @Query and ModelActor co-exist? How?

Context:

  • The SwiftUI @Query macro has an internal modelContext.
  • The ModelActor also has a modelContext, from which the data should be read/written.

Issue:

  • When writing to @Model data fetched with @Query macro using a ModelActor, it will crash in the most not-obvious ways.
  • Also, fetching @Model with ModelActor will result in errors in Swift 6 since @Model aren't sendable.

Problem to Solve:

- How to write a good amount of data to SwiftData/CoreData without blocking the UI thread?

  • Would the recommendation from the Apple team be that a large amount of data should be read/written with ModelActor and a small amount should be done with the @Query's internal modelContext ?

I think the following post answers your question, but please feel free to follow up, if you think it doesn't:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Can @Query and ModelActor co-exist? How?
 
 
Q