State restoration doesn't work, even with BNR solution code


Christian, this chapter has some serious problems. I’m using Xcode 5.1.1 and have testing the code on both my iPad device with iOS 7.1.2 AND with the iPAD simulator targeting iOS 7.0 and 7.1.

First, I tried the experiment suggested at the beginning of the chapter to look for screen flicker when an app is killed. I can’t reproduce what you suggest should be happening so perhaps Apple has changed and doesn’t use the screenshot taken just before an app enters background when it knows that the app is starting fresh from a new launch.

Secondly, after entering all of the suggested code and testing it, it simply does not work on either a real device or the simulator. I even downloaded the solution code from the BNR website and tested it on an iPad and the simulator. Same result … it doesn’t work.

Has somethings changed in iOS that makes this chapter out of date and no longer functional?


One recommendation for anyone having trouble getting state restoration to work is to delete all the items you have saved in your test app and create new ones. This should be an early ~troubleshooting step for any issues in this chapter, thus making sure that everything has a restoration identifier. Make sure to go in the background and come back and make sure they are deleted. Then create new items.

For me, for example most recently, I was having trouble getting the encoding part to work so that the BNRDetailViewController would restore with the previous data. I noticed that encodeRestorableStateWithCoder: wasn’t getting called (but decode was) - I think because my items were created previously and addNewItem was never called from BNRItemsViewController. “Starting over” with new data ensured that everything was created as needed from end-end.

Arguably creating new data end-to-end is somewhat obvious and/or is a best-practice, but I didn’t find it as obvious here and/or was distracted as I kept leaving/coming back in this long chapter.


I’m having the exact same issue. However I see that I can restore to the add new item detail view but not the detail view of an item already created. Anybody have any solutions?