iOS app state restoration demo
Example project that shows how to implement state restoration in iOS app that does not use storyboards.
Requirements:
- Open
StateRestoration.xcodeproj. - 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.
- Selected tab
- Navigation controllers stack
- View controllers titles
- Stepper values
UITabBarControllerandUINavigationControllermanages state restoration without the need to add any code, apart from settingrestorationIdentifierproperty on each of them.UIViewControllersubclasses need to implement several methods fromUIViewControllerRestorationandUIStateRestoringprotocols 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