Skip to content

Commit

Permalink
mirrored fix for watch app scene-create crash #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Oct 14, 2023
1 parent c1767e3 commit a7b48ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/WatchApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ struct Watch_App: App {
.environmentObject(coreDataStack)
}
.onChange(of: scenePhase) { _ in
// save if: (1) app moved to background, and (2) changes are pending
// save if transitioning to inactive or background
guard scenePhase == .inactive || scenePhase == .background else { return }

// and changes are pending
do {
try coreDataStack.container.viewContext.save()
} catch {
Expand Down

0 comments on commit a7b48ba

Please sign in to comment.