title: Swift - Unwind Segue Pass Data Confusion
body: <p>I've tried passing data backward from my unwind segue in a number of ways. It seems like the data is not getting sent or its getting sent after viewDidLoad() so the label I'm trying to set isn't getting updated. The unwind segue is working, and below I use prepare for segue with some success to change the title of the previous view controller to 'new title',  but the last line isn't setting nbaRotoHome.player to 'new player name'. </p>
  
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  
      if segue.identifier == "BuyStatsTapPager" {
          let nav = segue.destination as! UINavigationController
  
  
          let buyStatsTapPager = nav.viewControllers[0] as! BuyStatsTabPager
              buyStatsTapPager.selectedPlayerBuyStats = selectedPlayer
              buyStatsTapPager.buyStatsRef = self
  
      }
  
      if segue.identifier == "unwindToViewController1" {
  
          var viewControllers: [UIViewController] = mainNavigationController.viewControllers as [UIViewController];
  
          if(viewControllers.count == 3){
              viewControllers.remove(at: viewControllers.count-2)
              mainNavigationController?.viewControllers = viewControllers
          }
  
          let enteredContestViewController = viewControllers[viewControllers.count-1]
          enteredContestViewController.title = "new title"
  
          self.presentingViewController?.dismiss(animated: true, completion: nil)
  
          let nbaRotoHome = segue.destination as! NBARotoHome
  
          nbaRotoHome.player = "new player name"
  
  
      }
  </code></pre>
  
  <p>Back in my previous view controller I have     </p>
  
  <pre><code>@IBAction func prepareForUnwind(segue: UIStoryboardSegue) {
  
  
  }
  </code></pre>
  
  <p>And after looking at this question
  <a href="https://stackoverflow.com/questions/35313747/passing-data-with-unwind-segue">Passing data with unwind segue</a>
  I've also tried getting the data this way in the previous view controller</p>
  
  <pre><code> @IBAction func prepareForUnwind(segue: UIStoryboardSegue) {
      if let sourceViewController = segue as? BuyStats {
          playerNameLabel.text = sourceViewController.playerName
      }
  }
  </code></pre>
  
  <p>If I need to add more detail to what I'm trying to do please ask and I will edit. I wanted to ask the question but I am having trouble formulating. </p>