Kodeco Forums

State Restoration Tutorial: Getting Started

In this state restoration tutorial, learn how to use Apple's State Restoration APIs to enhance a user's experience of your app.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1395-state-restoration-tutorial-getting-started

hi,

I was adding the functionality in your tutorial to an app tutorial i was working on: cloudkit/microphone tutorial, because I wanted to deal with a situation where the user does not give or does give permission to use the microphone and then they go into settings and change it. as it stands, that crashes the app. I’d like to save the state of the app and not have a hung app sitting there when the user tries to come back, as it is now. (edit: I noticed that the app comes back more normally when Xcode isn’t there running it on the device…)

one thing that happened when I added your code was I got this error: Warning: Unable to create restoration in progress marker file

I’m not sure how to proceed.

is this something that could be used for a sprite kit game ?

You guys do such a great job!!
Any version for obj c??

I had a problem with state restoration and not wanting to show an animation when restoring a viewcontroller. You just need to add this to the AppDelegate:

func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { self.window?.makeKeyAndVisible() return true }

More discussion about the topic can be found from:
http://stackoverflow.com/questions/26461689/ios-state-restoration-animation-bug

Is decodeRestorableStateWithCoder(coder: NSCoder) called before or after viewDidLoad? I used this tutorial and it seemed to work quite well. The tableViewController I am restoring gets info from an http request in viewDidLoad. This seems to be called before decodeRestorableStateWithCoder.

Converted the final result to Swift 3 here:

https://github.com/AZCoder2/PetFinder.git

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]