I have a class that is not part of the UI in which I use with SwiftData. For the fetch method, I pass in the model context and use modelContext.fetch(fetchDescriptor). I also pass in the modelContext to the save method and just use do/try/catch for the insert/update/save calls as I would in a View. It all works fine.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: