title: Pass data to View Controller embedded inside a Container View Controller
body: <p>My view controller hierarchy is the following:</p>
  
  <p><a href="https://i.stack.imgur.com/PRc29.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PRc29.png" alt="view controller hierarchy"></a></p>
  
  <ul>
  <li>The entry point is a <code>UINavigationController</code>, whose root view controller is a usual <code>UITableViewController</code>. The Table View presents a list of letters.</li>
  <li>When the user taps on a cell, a <em>push segue</em> is triggered, and the view transitions to <code>ContainerViewController</code>. It contains an embedded <code>ContentViewController</code>, whose role is to present the selected letter on screen.</li>
  </ul>
  
  <p>The Content View Controller stores the letter to be shown as a property <code>letter: String</code>, which should be set before its view is pushed on screen.</p>
  
  <pre class="lang-swift prettyprint-override"><code>class ContentViewController: UIViewController {
  
      var letter = "-"
      @IBOutlet private weak var label: UILabel!
  
      override func viewWillAppear(animated: Bool) {
          super.viewWillAppear(animated)
          label.text = letter
      }
  }
  </code></pre>
  
  <p>On the contrary, the Container View Controller should not know anything about the letter (content-unaware), since I'm trying to build it as reusable as possible.</p>
  
  <pre class="lang-swift prettyprint-override"><code>class ContainerViewController: UIViewController {
  
      var contentViewController: ContentViewController? {
          return childViewControllers.first as? ContentViewController
      }
  }
  </code></pre>
  
  <p>I tried to write <code>prepareForSegue()</code> in my Table View Controller accordingly :</p>
  
  <pre class="lang-swift prettyprint-override"><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      if let containerViewController = segue.destinationViewController as? ContainerViewController {
          let indexPath = tableView.indexPathForCell(sender as! UITableViewCell)!
          let letter = letterForIndexPath(indexPath)
          containerViewController.navigationItem.title = "Introducing \(letter)"
          // Not executed:
          containerViewController.contentViewController?.letter = letter
      }
  }
  </code></pre>
  
  <p>but <strong><code>contentViewController</code> is not yet created by the time this method is called</strong>, and the letter property is never set.</p>
  
  <p>It is worth mentioning that this does work when the segue's destination view controller is set directly on the Content View Controller -- after updating <code>prepareForSegue()</code> accordingly.</p>
  
  <p>Do you have any idea how to achieve this?</p>