iOS State Restoration
iOS app state restoration demo
Example project that shows how to implement state restoration in iOS app that does not use storyboards.
- Build and run
StateRestorationAppscheme in iOS simulator.
- Play with the app a bit, change stepper value, push new view controllers etc.
- Kick the app to background (press ⇧ + ⌘ + H) to save current state.
- Stop running the app in Xcode.
- Start the app again (from Xcode or directly in simulator).
- Previous state should be restored.
The "state" of demo app is:
- Selected tab
- Navigation controllers stack
- View controllers titles
- Stepper values
UINavigationControllermanages state restoration without the need to add any code, apart from setting
restorationIdentifierproperty on each of them.
UIViewControllersubclasses need to implement several methods from
UIStateRestoringprotocols to save and restore their state.
- The saved state is removed if you "kill" the app from iOS task switcher.
Copyright © 2019 Dariusz Rybicki Darrarski
License: GNU GPLv3