title: Prepare for Segue to UITabBarController Tab
body: <p>I want to pass information from a <code>ViewController</code> to a <code>UITabBarController</code> so that I can access certain information from the view controller in the 3rd tab of the <code>UITabBarController</code>.</p>
  
  <p>However, the issue is my program keeps crashing when I try to do so. Here is my code so far:</p>
  
  <p>I call the segue like so:</p>
  
  <pre><code>self.firstName = user.first_name
  self.lastName = user.last_name
  self.performSegueWithIdentifier("OffersView", sender: self)
  </code></pre>
  
  <p>And I override the <code>prepareForSegue</code> function so that I can pass information in this function like so:</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      if(segue.identifier == "OffersView"){
          let barViewControllers = segue.destinationViewController as UITabBarController
          let destinationViewController = barViewControllers.viewControllers![2] as ProfileController
          destinationViewController.firstName = self.firstName
          destinationViewController.lastName = self.lastName
      }
  }
  </code></pre>
  
  <p>When I try to set the <code>destinationViewController</code> (on the second line in the code above), my code crashes. I'm not sure why as I've looked on numerous StackOverflow posts such as</p>
  
  <p><a href="https://stackoverflow.com/questions/27307903/swift-tab-bar-view-prepareforsegue">Swift tab bar view prepareforsegue</a> and <a href="https://stackoverflow.com/questions/27296742/pass-data-from-tableview-to-tab-bar-view-controller-in-swift">Pass data from tableview to tab bar view controller in Swift.</a> but have not have much success. Do I possibly need to create a <code>UITabBarControllerDelegate</code> class and pass information through that? Any tips would be appreciated. Thanks!</p>