The best way I've seen online is to hook into the ScenePhase & to iterate over your data:
///struct <YourApp>: App {...
.onChange(of: scenePhase) { _, newValue in
if case .active = newValue {
items.forEach { $0.title = $0.title }
}
}
//Or do something like the following:
modelContainer = DataModel.shared.modelContainer
I don't think we're allowed to link out here, but lookup "Widget-Intermediate-Animation" on GitHub for more info & the new SwiftData History stuff.
When using Shortcuts/App Intents, I've yet to find a good way to update the main UI (The data is being manipulated, but the UI isn't redrawing)... I've been using the above which works when navigating out/into a NavStack view or backgrounding & re-foregrounding the app.
Ie, less than ideal, but we do what we gotta do! 😅
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: