title: Save and restore UINavigation stacks to reconnect
body: <p>I am currently having a hard time understanding what I should use to save and restore my app state.</p>
  <p>I am using a storyboard and I have quite some ViewControllers, and I want to save all my navigation stacks when the app is terminated to be able to restore all the navigation when the user relaunch the application.</p>
  <p>I am using a <code>UINavigationController</code> with another UINavigationController inside it just for information.</p>
  <p>I found this and read this over and over :
  <a href="https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html#//apple_ref/doc/uid/TP40007457-CH28-SW34" rel="noreferrer">https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html#//apple_ref/doc/uid/TP40007457-CH28-SW34</a></p>
  <blockquote>
  <p>(Required) Assign restoration identifiers to the view controllers whose configuration you want to preserve; see Tagging View Controllers for Preservation.</p>
  <p>(Required) Tell iOS how to create or locate new view controller objects at launch time; see Restoring View Controllers at Launch Time.</p>
  </blockquote>
  <p>Then I added a <code>RestorationId</code> on all my ViewControllers but I don't understand what I should do for the second part as when I add <code>viewControllerWithRestorationIdentifierPath</code> methods I don't pass inside.</p>
  <p>I also tried to save the <code>navigation.viewcontrollers</code> into the NSUserDefaults in order to use them again when the user restart the app
  using the code :</p>
  <pre><code>+(NSArray *) getNavStatus
  {
      NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
      id objectSaved;
      if( (objectSaved = [preferences objectForKey:navStatusKey]) != nil)
          return [NSKeyedUnarchiver unarchiveObjectWithData:objectSaved];
      else
          return nil;
  }
  
  +(BOOL) saveNavStatus:(UINavigationController *) nav
  {
      NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
      
      NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:nav.viewControllers];
      [preferences setObject:encodedObject forKey:navStatusKey];
      
      //  Save to disk
      return [preferences synchronize];
  }
  </code></pre>
  <p>But when I get back in the app apple stats to tell me that the constraint ain't respected and that the app will crash and then when I add the viewControllers in the stack of my navigation it does crash :)</p>
  <p>Any tips or help would be much appreciated.
  Thanks a lot</p>