title: Cannot access UITabBarController from modal ViewController
body: <p>I have a <code>UITabBarController</code>-based application in which my <strong>login page</strong> is presented modally by the default tab's VC(UITabBarController index 0), and is dismissed modally by <code>dismissViewControllerAnimated:</code>. </p>
  
  <p>From my <strong>settings page</strong> I have a <em>logout</em> button, and if the user immediately logs back in I have to call <code>[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];</code> and then reset the <code>UITabBarController</code>'s <strong>selectedIndex</strong> property in order to get rid of the settings page and also go back to the starting tabBar tab. So I do this:</p>
  
  <pre><code>-(void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      NSString* responseString = [[NSString alloc] initWithData:_responseData encoding:NSUTF8StringEncoding];
  
      /*Succesful Login*/
      if([responseString isEqualToString:@"success"])
      {
          UITabBarController *tabBarController = (UITabBarController *)self.presentingViewController;
  
          if (tabBarController){
              NSLog(@"I have a tab bar~");
              [self.tabBarController setSelectedIndex:0];
          }
          else{
              NSLog(@"I don't have a tab bar~");
          }
  
          //dismisses from a second, immediate, re-login attempt
          [self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
          //dismisses from first login attempt
          [self dismissViewControllerAnimated:YES completion:nil];
  
          NSLog(@"Succesful login.");
      }
  </code></pre>
  
  <p>In this case, the method <code>setSeletedIndex:</code> does not work because this methodology essentially creates a new instance of the tabBarController, when it is the original that is actually displayed. I CAN NOT seem to access the <strong>already existing</strong> <code>UITabBarController</code> which was before my modally presented login page.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have tried using this conditional to check its existence:</p>
  
  <pre><code>if (self.tabBarController){
      NSLog(@"I have a tab bar~");
      //[self.tabBarController setSelectedIndex:0];
  }
  else{
      NSLog(@"I don't have a tab bar~");
  }
  </code></pre>
  
  <p>where I have even changed <strong>self.tabBarController</strong> to self.presentingViewController.tabBarController and get nil, and self.presentingViewController.presentingViewController.tabBarController and get nil, how am I to access the previously existing <code>UITabBarController</code>?</p>
  
  <p><em>Objective:</em> Access the application's UITabBarController that is present before the presentation of the login page. (Access the Appdelegate's UITabBarController)</p>