I try to do some SwiftData work on the background thread using the next code, while I set "Strict Concurrency Check" to "Complete", I get a warning message. the "List Item" is a SwiftData model. the code:
@ModelActor
actor DataModelActor {
func configureNewListItem() -> ListItem {
let newListItem = ListItem(index: 0, pinIndex: 0)
modelContext.autosaveEnabled = false
modelContext.insert(newListItem)
return newListItem
}
}
The warring message:
I get "modelContext" from:
@Environment(\.modelContext) private var modelContext
How can fix the warning message (I don't want to ignore it) or is there another way to use SwiftData by avoiding the main thread? Please.
