title: Disable/Enable tabs in UITabBarController in storyboard-based app
body: <p>I've built my app with storyboards and all views are managed by a tabbarcontroller. </p>
  
  <p>So on launch (I'm only working on the iPad UI currently) it does this:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
      {
          UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
          UISplitViewController *splitViewController = [tabBarController.viewControllers objectAtIndex:0];
          UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
          splitViewController.delegate = (id)navigationController.topViewController;
  
          UINavigationController *masterNavigationController = [splitViewController.viewControllers objectAtIndex:0];
          ProductionMasterViewController *controller = (ProductionMasterViewController *)masterNavigationController.topViewController;
          controller.managedObjectContext = self.managedObjectContext;
      }
  }
  </code></pre>
  
  <p>I want to be able to enable or disable the tabs in the tabBarController based on user input (so, for example, an item needs to be selected in the first tab in order to access the second and third tabs, which are disabled by default) </p>
  
  <p>What I'm not clear on is how to access the tabs in order to enable/disble them. Would I create an instance of the appdelegate and then do something like </p>
  
  <pre><code>AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  UITabBarController *tabs = (UITabBarController *)[d.window rootViewController];
  [[[[tabs tabBar] items] objectAtIndex:2] setEnabled:YES];
  [[[[tabs tabBar] items] objectAtIndex:3] setEnabled:YES];
  [[[[tabs tabBar] items] objectAtIndex:4] setEnabled:YES];
  </code></pre>
  
  <p>(That kinda seems like it should work but it also seems fairly gross.)</p>