title: Share Data Between View Controller and Container View
body: <p>I have a view controller that has a segue to a second view controller, and I passed some data to the second one in prepare for segue.
  The problem is: the second view controller has a container view which I need to share that data with. I tried using prepare for segue but it didn't work in this case.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>View Controller code:</p>
  
  <pre><code>class ViewController: UITableViewController, ContainerViewDelegate {
  
     var myContainerView = ContainerView()
     var id: String!
  
     override func viewDidLoad() {
          super.viewDidLoad()
          id = "123"
          myContainerView.delegate = self
     }
  
     func initialize() -&gt; String {
          return id
     }
  }
  </code></pre>
  
  <p>Container view code:</p>
  
  <pre><code>protocol ContainerViewDelegate {
     func initialize() -&gt; String
  }
  
  class ContainerView: UICollectionViewController {
  
     var delegate: ContainerViewDelegate!
     var id: String!
     override func viewDidLoad() {
         super.viewDidLoad()
         id = delegate.initialize()
         print(id)
     }
  }
  </code></pre>
  
  <p>I get error: <code>fatal error: unexpectedly found nil while unwrapping an Optional value</code> at the line: <code>id = delegate.initialize()</code> </p>