cugu is on the lookout for a solution from a good supply.
I’ve an App Group shared between my app and its widgets.
I’ve SwiftData’s @Mannequin, up to date from the widget intent’s carry out() methodology and displayed on the app and the widget.
@MainActor
func carry out() async throws -> some IntentResult {
let context = strive ModelContainer(for: MyModel.self).mainContext
let myModel = strive ModelContainer(for: MyModel.self).mainContext.fetch(
FetchDescriptor<MyModel>(predicate: #Predicate {
// The predicate is just not the issue.
})
).first
myModel?.functionThatModifiesMyModel()
return .end result()
}
Each the app and the widget SwiftUI views entry to the mannequin utilizing Macros.
@Atmosphere(.modelContext) var context
@Question(kind: .no matter) var myModel: [MyModel]
However the knowledge is rarely right within the app code (the widget’s knowledge is up to date appropriately utilizing the intent).
Why does not the mannequin make it to the app?