title: iPhone, UITabBarItem: Dynamically change image of a tab bar when app starts
body: <p>When my app loads I want to change the image on one of the tabs based on a saved setting set by the user the last time they ran the app.  I am able to change the image when the user clicks on the tab which executes that tab's viewcontroller's ViewDidLoad method.  see below: </p>
  
  <pre><code>UITabBarItem *tabItem;
  if (condition = YES) { 
      tabItem = [[UITabBarItem alloc] initWithTitle:@"Filter" image:[UIImage imageNamed:@"filter plus.png"] tag:self.view.tag];
  }
  else {
      tabItem = [[UITabBarItem alloc] initWithTitle:@"Filter" image:[UIImage imageNamed:@"filter.png"] tag:self.view.tag];
  }
  self.navigationController.tabBarItem = tabItem;
  [tabItem release];
  [super viewDidLoad]; 
  </code></pre>
  
  <p>But I have been unable to figure out how to access and change the UITabBarItem of that tab in the root view controller of the app when it loads.  See viewdidload method of root view controller below.</p>
  
  <pre><code>UITabBarItem *tabItem;
  if (condition = YES) { 
      tabItem = [[UITabBarItem alloc] initWithTitle:@"Filter" image:[UIImage imageNamed:@"filter plus.png"] tag:self.view.tag];
  }
  else {
      tabItem = [[UITabBarItem alloc] initWithTitle:@"Filter" image:[UIImage imageNamed:@"filter.png"] tag:self.view.tag];
  }
  // get the view controller of the tab I want to change
  MyViewController *vc = [self.tabBarController.viewControllers objectAtIndex:2];
  ft.tabBarItem = tabItem;
  [tabItem release];
  [super viewDidLoad]; 
  </code></pre>
  
  <p>When this did not work I tried multiple other ways to access and change the uitabbaritem but nothing worked. I tried creating IBOutLets in the root view controller to UITabBarItem and UINavigationController.</p>
  
  <pre><code>// tb is an iboutlet to the UITabBarItem
  self.tb = tabItem;  
  
  // nc is an iboutlet to the UINavigationController
  self.nc.tabBarItem = tabItem;   
  </code></pre>
  
  <p>to no avail.  Any idea how to do this?</p>