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
StateRestorationApp
scheme 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
UITabBarController
andUINavigationController
manages state restoration without the need to add any code, apart from settingrestorationIdentifier
property on each of them.UIViewController
subclasses need to implement several methods fromUIViewControllerRestoration
andUIStateRestoring
protocols 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