title: How to implement only one table controller for all segment in pager?
body: <p>I am implementing custom horizontal multiple segments with table view controller as content of each segment. But how to implement only one controller for all segments, because view is same for all segments but only  data is change.
  I want to pass current index of segment to table view controller to get particular data.
  I am using CAPSPageMenu.swift file from -<a href="https://codeload.github.com/uacaps/PageMenu/zip/master" rel="nofollow">https://codeload.github.com/uacaps/PageMenu/zip/master</a>?</p>
  
  <p>here is my code-</p>
  
  <pre><code>class Entrance_main_controller: UIViewController {
  
               var pageMenu : CAPSPageMenu?
  
  
  
  override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)
  
      // MARK: - UI Setup
  
      self.title = "Entrance Exam"
  
      // Initialize view controllers to display and place in array
      var controllerArray : [UIViewController] = []
  
  
  
      let controller1 : Entrance_Content_ViewController =         Entrance_Content_ViewController(nibName: "TestTableViewController", bundle: nil)
      controller1.title = "Engineering"
      controllerArray.append(controller1)
      let controller2 : Entrance_Content_ViewController = Entrance_Content_ViewController(nibName: "TestTableViewController", bundle: nil)
      controller2.title = "Medical"
      controllerArray.append(controller2)
  
      let controller3 : Entrance_Content_ViewController = Entrance_Content_ViewController(nibName: "TestTableViewController", bundle: nil)
      controller3.title = "Management"
      controllerArray.append(controller3)
  
      // Customize menu (Optional)
      let parameters: [CAPSPageMenuOption] = [
          .ScrollMenuBackgroundColor(UIColor(red: 30.0/255.0, green: 30.0/255.0, blue: 30.0/255.0, alpha: 1.0)),
          .ViewBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
          .SelectionIndicatorColor(UIColor.orangeColor()),
          .BottomMenuHairlineColor(UIColor(red: 70.0/255.0, green: 70.0/255.0, blue: 80.0/255.0, alpha: 1.0)),
          .MenuItemFont(UIFont(name: "HelveticaNeue", size: 13.0)!),
          .MenuHeight(40.0),
          .MenuItemWidth(90.0),
          .CenterMenuItems(true)
      ]
  
      // Initialize scroll menu
      pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)
  
      self.addChildViewController(pageMenu!)
      self.main_content_view.addSubview(pageMenu!.view)
  
      pageMenu!.didMoveToParentViewController(self)
  }
   //here I am getting current index
  func get_current_page() -&gt; Int {
       let currentIndex = pageMenu!.currentPageIndex
      return currentIndex;
  }
  
  // MARK: - Container View Controller
  override func shouldAutomaticallyForwardAppearanceMethods() -&gt; Bool {
      return true
  }
  
  override func shouldAutomaticallyForwardRotationMethods() -&gt; Bool {
      return true
  }
  }
  </code></pre>
  
  <p>here I am using Entrance_Content_ViewController class for all segments.In this controller I am calling <strong>get_current_page()</strong> method for current page index.</p>
  
  <pre><code>class Entrance_Content_ViewController: UITableViewController {
  
   override func viewDidLoad() {
   super.viewDidLoad()
  
   let entrance_main_controller = Entrance_main_controller()
      let page = entrance_main_controller.get_current_page()
      print("page no\(page)")
  
      self.tableView.registerNib(UINib(nibName: "EntranceTableViewCell",        bundle: nil), forCellReuseIdentifier: "EntranceTableViewCell")
  
          }
  </code></pre>
  
  <p>But I am getting this error- <strong>fatal error: unexpectedly found nil while unwrapping an Optional value(lldb)</strong>
  Please help me to solve this problem.
  thank you </p>