Skip to content

State restoration in iOS app that does not use storyboards

License

Notifications You must be signed in to change notification settings

darrarski/iOS-State-Restoration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS State Restoration

swift v5.0 platform iOS

iOS app state restoration demo

Example project that shows how to implement state restoration in iOS app that does not use storyboards.

Setup

Requirements:

Description

How to:

  1. Open StateRestoration.xcodeproj.
  2. Build and run StateRestorationApp scheme in iOS simulator.
  3. Play with the app a bit, change stepper value, push new view controllers etc.
  4. Kick the app to background (press + + H) to save current state.
  5. Stop running the app in Xcode.
  6. Start the app again (from Xcode or directly in simulator).
  7. Previous state should be restored.

The "state" of demo app is:

  • Selected tab
  • Navigation controllers stack
  • View controllers titles
  • Stepper values

Hints:

  • UITabBarController and UINavigationController manages state restoration without the need to add any code, apart from setting restorationIdentifier property on each of them.
  • UIViewController subclasses need to implement several methods from UIViewControllerRestoration and UIStateRestoring protocols to save and restore their state.
  • The saved state is removed if you "kill" the app from iOS task switcher.

License

Copyright © 2019 Dariusz Rybicki Darrarski

License: GNU GPLv3

About

State restoration in iOS app that does not use storyboards

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages