title: iOS State Restoration of UITabBarController Does Not Restore Child View Controllers or Selected Index
body: <p>(This is my first time asking a question on StackOverflow, so forgive me if there are issues)</p>
  
  <p>My problem comes down to not being able to properly restore the state of a <code>UITabBarController</code>. This is a tab-based application and I am not using Storyboards.</p>
  
  <p>I have opted into state restoration. I have provided all of my custom <code>ViewController</code>s with unique restoration identifiers and restoration classes in their respective <code>init</code> methods.</p>
  
  <p>As for the <code>UITabBarController</code>, I provide it with a unique restoration identifier when it is created. Because I do not give it a restoration class, I have implemented the following code in the app delegate:</p>
  
  <pre><code>- (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder 
  {
      UITabBarController *vc = [[UITabBarController alloc] init];
  
      vc.restorationIdentifier = [identifierComponents lastObject];
  
      if ([identifierComponents count] == 1) {
          self.window.rootViewController = vc;
      }
  
      return vc;
  }
  </code></pre>
  
  <p>I have used the same method in other apps to restore the state of <code>NavigationController</code>s, and everything goes smoothly. However, when I do it for this app with the <code>TabBarController</code>, the application launches with an empty <code>TabBarController</code> (the <code>TabBarController</code> is restored, but it does not restore it's child view controllers). </p>
  
  <p>This isn't a huge shock to me, I suppose that just by nature <code>UITabBarController</code>s do not keep references to their child view controllers not the selected tab index for state restoration. However, despite many hours searching online, I could not any instructions on how to preserve the state of a <code>TabBarController</code> (without <code>storyboard</code>). Any help on how to do this would be tremendously appreciated.</p>
  
  <p>Again, I'm sorry if I did not provide enough detail or wasn't clear enough. Please just let me know what you need in your answers and I'll provide it. I know I didn't provide much of my code, but I really just need instructions on how to preserve the state of a Tab-based application without storyboards. It does not need to be tailored to my specific case; I will be able to apply the general process myself.</p>
  
  <p>Thanks!</p>