title: PageViewController pass data to child controller
body: <p>I have a page view controller with array referencing storyboards ID of controllers, that I want to show inside. How can I pass data from root controller to controllers indside ?</p>
  
  <p>I tried do to like this but it fails</p>
  
  <pre><code>func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
  
      if let index = pages.indexOf(viewController.restorationIdentifier!) {
  
          if index &lt; pages.count - 1 {
              return viewcontrollerAtIndex(index + 1)
          }
  
      }
  
      var objectController = viewcontrollerAtIndex(0) as! HF2Object
      objectController.object = object
      objectController.serverID = serverID
      objectController.imageURLsArray = imageURLsArray
  
  
      return nil
  }
  </code></pre>
  
  <p>Whole controller code</p>
  
  <pre><code>import UIKit
  
  class HF2PageViewController: UIViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
  
  var pages = ["object", "reviews"]
  var pageViewController = UIPageViewController()
  var object:String?
  var serverID:String?
  var imageURLsArray = [String]()
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      pageViewController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
      pageViewController.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + 64, self.view.frame.width, self.view.frame.height - 64)
  
      addChildViewController(pageViewController)
      self.view.addSubview(pageViewController.view)
  
      pageViewController.delegate = self
      pageViewController.dataSource = self
  
      pageViewController.setViewControllers([viewcontrollerAtIndex(0)], direction: .Forward, animated: true, completion: nil)
      pageViewController.didMoveToParentViewController(self)
  
  
  }
  
  func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -&gt; UIViewController? {
  
      if let index = pages.indexOf(viewController.restorationIdentifier!) {
  
          if index &lt; pages.count - 1 {
              return viewcontrollerAtIndex(index + 1)
          }
  
      }
  
      var objectController = viewcontrollerAtIndex(0) as! HF2Object
      objectController.object = object
      objectController.serverID = serverID
      objectController.imageURLsArray = imageURLsArray
  
  
      return nil
  }
  
  func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController? {
  
      if let index = pages.indexOf(viewController.restorationIdentifier!) {
  
          if index &gt; 0 {
              return viewcontrollerAtIndex(index - 1)
          }
  
      }
  
      return nil
  }
  
  func viewcontrollerAtIndex(index: Int) -&gt; UIViewController {
      let vc = storyboard?.instantiateViewControllerWithIdentifier(pages[index])
      return vc!
  }
  </code></pre>
  
  <p>}</p>