We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1767e3 commit a7b48baCopy full SHA for a7b48ba
Sources/WatchApp.swift
@@ -35,7 +35,10 @@ struct Watch_App: App {
35
.environmentObject(coreDataStack)
36
}
37
.onChange(of: scenePhase) { _ in
38
- // save if: (1) app moved to background, and (2) changes are pending
+ // save if transitioning to inactive or background
39
+ guard scenePhase == .inactive || scenePhase == .background else { return }
40
+
41
+ // and changes are pending
42
do {
43
try coreDataStack.container.viewContext.save()
44
} catch {
0 commit comments