title: How to remove programmatically a tab bar item created in parent class NIB file?
body: <p>Within my iPhone application I have a common tab bar with <em>three tabs</em> that is presented from several views after pressing a button. The approach I followed was the workflow of Tweetie application, described in <a href="http://www.wiredbob.com/blog/2009/4/20/iphone-tweetie-style-navigation-framework.html" rel="noreferrer">Robert Conn post</a>.</p>
  
  <p>Note that the main controller is a navigation controller; the tab bar is placed in a view controller's NIB file of the navigation stack, and the effect of switching between tabs is handled in a delegate didSelectItem method.</p>
  
  <pre><code>@interface GameTabBarController : UIViewController&lt;UITabBarDelegate&gt; {
    UITabBar *tabBar;
    UITabBarItem *lastGameTabBarItem;
    UITabBarItem *previousGamesTabBarItem;
    UITabBarItem *myBetsTabBarItem;
  
    NSArray *viewControllers;
    UIViewController *currentViewController;
  }
  
  @implementation GameTabBarController
    ...
  
    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
      UIViewController *viewController = nil;
  
      // Get the view controller linked to the tab bar item pressed
      ...
  
      // Switch to the view
      [self.currentViewController.view removeFromSuperview];
      [self.view addSubview:viewController.view];
      self.currentViewController = viewController;
    }
  
    ...
  @end
  </code></pre>
  
  <p>Since the views of the tab bar must be customized according to the view controller the application came from, I have made this <code>GameTabBarController</code> a parent class with that NIB file that have the tab bar. Then, I have created several children classes:</p>
  
  <pre><code>@interface FirstGameTabBarController : GameTabBarController {
    ...   
  }
  
  @interface SecondGameTabBarController : GameTabBarController {
    ...   
  }
  
  ...
  </code></pre>
  
  <p>My problem is that in some of the children classes I would like to remove the third tab of the NIB file associated with parent class. But since there is no UITabBarController involved, I cannot follow typical approaches you can found on the web, i.e. removing the view controller of the tab bar item.</p>
  
  <p>How can I do that? Is it possible to remove elements that has been previously added in a NIB file?</p>
  
  <p>Thanks!!</p>
  
  <p><strong>UPDATE</strong>
  The solution was so easy... I have just to replace the tab bar items, instead of the view controllers:</p>
  
  <pre><code>NSMutableArray *items = [NSMutableArray arrayWithArray:self.tabBar.items];
  [items removeObjectAtIndex:2];
  [self.tabBar setItems:items];
  </code></pre>
  
  <p>Thanks to @Praveen S for pointing me in the right direction.</p>