state restoration in iOS
Asked Answered
S

3

16

I am storing my application screen, so that when the application gets opened it will show the screen that was stored. The application is navigation based.

I have assigned the Restoration Ids to my two view controllers in main story board. The first controller is the root view controller of the navigation controller. I have also assigned Restoration Id to the navigation controller. Now the problem is when I run the application I am getting the following warning:

Unable to create restoration in progress marker file.

Not sure what else need to be done.

Salep answered 17/10, 2013 at 10:49 Comment(2)
I would suggest taking the time to read the Apple documentation on state preservation and restoration. State Preservation and Resrvation Apple DocArnoldoarnon
possible duplicate of Cryptic warning without any google results [In Simulator]Lickerish
F
10

I had the same warning before and fixed it by doing the followings.

I was using storyboard. My storyboard only included a navigation view controller and a view controller (which was the root view controller of that navigation view controller). In my case, it was caused by either of the two reasons:

The application was not set up correctly for state preservation The followings need to be set:

  1. In app delegate, override application:willFinishLaunching. One can simply return YES in that method.

  2. For every view controllers and views (including the navigation view controllers and tab view controllers), set a restore ID

  3. In app delegate, opt-in by overriding shouldSaveApplicationState and shouldRestoreApplicationState

If this warning still occurred, you could check how you run your app in Xcode. I ran my app in Xcode simulator and had to follow a specific sequence to trigger state preservation.

  • launch the app in Xcode simulator
  • In Xcode simulator, click the "Home" button to put the app into the background. The encodeRestorableStateWithCoder method of the view controller should be called
  • go back to Xcode, click the "stop" button to terminate the simulation
  • In Xcode simulator, double click the "Home" button and then remove the app from the app switcher and
  • go back to Xcode, run the app again.

That warning should not appear. When I used other sequences, I saw that warning appearing. When I debugged my app on my device using Xcode, I followed the same sequence and did not see the warning.

I think that warning indicated that because Xcode could not terminate the app correctly, the state restoration file was not correctly saved onto the disk.

Fajardo answered 23/11, 2013 at 1:29 Comment(1)
I'm pretty certain that you don't need to do step D above (force-quit the application in the simulator).Oaxaca
P
1

Try to give your View a restoration ID. You can do so to open your xib or storyboard and assign the id to your View Controller.

enter image description here

more details: http://useyourloaf.com/blog/2013/05/21/state-preservation-and-restoration.html

Pitzer answered 13/11, 2013 at 20:40 Comment(0)
Q
0

Simulator:

  • This happens for the first time on the simulator when the app encodes. (not sure why)
  • Subsequent times this warning wouldn't be shown.

Device:

Try running on the device.

  1. Run on device
  2. Go to home screen.
  3. Stop running on Xcode
  4. Remove app from app switcher
  5. Run on device again
Quadrillion answered 21/10, 2016 at 2:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.