title: Pass data to controller in container view
body: <p>I've got the following setup: a collection view with menu headers and menu items, when I select a menu item it should update the content on the right side of the view. In the right side of the view, I have a label and a segmented control.</p>
  
  <p>When I select an item, it should update the container views both (they have a controller with embed segue). When I select the segmented control, the different view controller will be loaded.</p>
  
  <p>Now I tried this:</p>
  
  <p><code>var selectedItem: String!
   var services: [String]!
  </code></p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      // Loaded collectionView and reloaded
      selectedItem = services[section].items[row]
  }
  </code></pre>
  
  <p>Then, I use <code>prepare(for:sender:)</code> to pass <code>selectedItem</code> to the controller that is being shown on the screen. However, this doesn't work, I think because the controller is already loaded.</p>
  
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          if segue.identifier == "overviewSegue" {
              let controller = segue.destination as! ServiceOverViewController
              if let item = selectedItem {
                  controller.setupViewWithService(service: item)
              }
          }
      }
  
  func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
          self.titleLabel.text = services[indexPath.section].items[indexPath.row].name
          let overview = services[indexPath.section].items[indexPath.row]
          selectedItem = overview
      }
  </code></pre>
  
  <p>How can I select an item in the collectionView, set the data in both of the controllers in the containerView?</p>