title: Passing Data to view controllers that are embedded in container views
body: <p>I have view controllers that just need to get passed a NSDictionary called "otherUser". I am using a segmented controller to conveniently present 4 of these views to a user using container views. I know all of these views will be loaded at the same time and will stay loaded, which is what I want even though the toll on memory. I know how to directly pass this value to the view controller but don't know how to pass it to a view controller that would then spread it to 4 views to load the same data. ---- Below is me passing "otherUser" to "BusinessProfileSwitchView"(View Controller with container views) based on the search bar actions. </p>
  
  <pre><code> override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      super.prepare(for: segue, sender: sender)
      if segue.identifier == "BusinessProfiles" {
          // gotta check if we're currently searching
          if self.searchController.isActive &amp;&amp; searchController.searchBar.text != "" {
              if let indexPath = tableView.indexPathForSelectedRow {
                  let user = filteredUsers[indexPath.row]
                  let controller = segue.destination as? BusinessProfileSwitchView
                  controller?.otherUser = user
              }
          } else {
              if let indexPath = tableView.indexPathForSelectedRow {
                  let user = usersArray[indexPath.row]
                  let controller = segue.destination as? BusinessProfileSwitchView
                  controller?.otherUser = user
              }
          }
      }
  }
  </code></pre>
  
  <p>What is the method of attack do you guys think I should use to pass "otherUser"/NSDictionary to the view controller with container views that would then spread "otherUser" to 4 views? Below is my view controller that connect to the other 4 views.</p>
  
  <pre><code> import UIKit
  
   class BusinessProfileSwitchView: UIViewController {
  
  @IBOutlet weak var feedView: UIView!
  @IBOutlet weak var collectionView: UIView!
  @IBOutlet weak var infoView: UIView!
  @IBOutlet weak var socialView: UIView!
  
  var infos: BusinessProfilesDetails!
  var collections: BusinessProfilePostsCollection!
  var feeds: BusinessProfilePostsFeed!
  var socials: BusinessProfilesViewController!
  
  @IBOutlet weak var switchController: UISegmentedControl!
  
  var otherUser: NSDictionary!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      switch  switchController.selectedSegmentIndex {
      case 0:
          infoView.isHidden = false
          feedView.isHidden = true
          collectionView.isHidden = true
          socialView.isHidden = true
          break
      case 1:
          infoView.isHidden = true
          feedView.isHidden = true
          collectionView.isHidden = false
          socialView.isHidden = true
          break
      case 2:
          infoView.isHidden = true
          feedView.isHidden = false
          collectionView.isHidden = true
          socialView.isHidden = true
          break
      case 3:
          infoView.isHidden = true
          feedView.isHidden = true
          collectionView.isHidden = true
          socialView.isHidden = false
          break
      default:
  
          break;
      }
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  @IBAction func viewControl(_ sender: UISegmentedControl) {
      switch  switchController.selectedSegmentIndex {
      case 0:
          infoView.isHidden = false
          feedView.isHidden = true
          collectionView.isHidden = true
          socialView.isHidden = true
          break
      case 1:
          infoView.isHidden = true
          feedView.isHidden = true
          collectionView.isHidden = false
          socialView.isHidden = true
          break
      case 2:
          infoView.isHidden = true
          feedView.isHidden = false
          collectionView.isHidden = true
          socialView.isHidden = true
          break
      case 3:
          infoView.isHidden = true
          feedView.isHidden = true
          collectionView.isHidden = true
          socialView.isHidden = false
          break
      default:
  
          break;
      }
  }
  </code></pre>
  
  <p>}</p>