title: prepareForSegue when embedding Tab Bar Controller into Navigation Controller
body: <p>I currently have a navigation controller setup like this: </p>
  
  <p><a href="https://i.stack.imgur.com/y9HhK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y9HhK.png" alt="enter image description here"></a></p>
  
  <p>and my prepareForSegue, that passes data between the initial view (Login View Controller) and the Navigation controller looks like such:</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
          super.prepareForSegue(segue, sender: sender)
          let navVc = segue.destinationViewController as! UINavigationController // 1
          let chatVc = navVc.viewControllers.first as! ChatViewController // 2
          chatVc.senderId = userID // 3
          chatVc.senderDisplayName = "" // 4
      }
  </code></pre>
  
  <p>However, when I try to embed in a Tab Bar controller (to add more pages/functionality to my app) like this...</p>
  
  <p><a href="https://i.stack.imgur.com/MTJ3U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MTJ3U.png" alt="enter image description here"></a></p>
  
  <p>...and run my application, my program crashes at the line <code>let navVc = segue.destinationViewController as! UINavigationController</code></p>
  
  <p>I know that the problem is that after my initial view, it goes to the tab bar which is type <code>UITabBarController</code> rather than <code>UINavigationController</code> however if I change it, my data does not go to the view that I want it to go to...it is kind of confusing.</p>
  
  <p>Please let me know if you have any ideas how to implement this, or if you have any questions feel free to ask me for clarification. </p>
  
  <p>Thanks!</p>
  
  <p>P.s. The error that I am receiving in the console is: </p>
  
  <pre><code>Could not cast value of type 'UITabBarController' (0x10b8e48b0) to 'UINavigationController' (0x10b8e4860).
  </code></pre>