Skip to content

Commit a7b48ba

Browse files
author
Reed Es
committed
mirrored fix for watch app scene-create crash #24
1 parent c1767e3 commit a7b48ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/WatchApp.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ struct Watch_App: App {
3535
.environmentObject(coreDataStack)
3636
}
3737
.onChange(of: scenePhase) { _ in
38-
// save if: (1) app moved to background, and (2) changes are pending
38+
// save if transitioning to inactive or background
39+
guard scenePhase == .inactive || scenePhase == .background else { return }
40+
41+
// and changes are pending
3942
do {
4043
try coreDataStack.container.viewContext.save()
4144
} catch {

0 commit comments

Comments
 (0)