Pick the fix
A SwiftUI app should reopen on the same detail screen after the system kills it. Best approach?
Hint 1 of 1
What is the smallest thing that describes where the user was?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Store the route path, such as ids, in @SceneStorage and rebuild the NavigationStack path from it
Correct. It's small, per scene, and restored automatically.
Why not the others?
- B Save the whole view model in UserDefaults. It's heavy, and goes stale.
- C Keep the app alive in the background. You can't prevent the system from ending it.
- D Use @State. @State is lost when the process ends.