title: Swipe between multiple view controllers using UIPageViewController
body: <p>My UIPageViewController not working at all. What I'm trying to do is switch 2 view controllers inside UIPageViewController. I already followed guideline here but fail. <a href="https://stackoverflow.com/questions/25387436/using-uipageviewcontroller-with-swift-and-multiple-view-controllers">Using UIPageViewController with swift and multiple view controllers</a>. First view controller appeared successful but when I tried swipe to second view controller it throw this error message. I already set all identifiers correctly.</p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  </code></pre>
  
  <p>It's cause from here</p>
  
  <pre><code>func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -&gt; UIViewController? {
  
          let identifier = viewController.restorationIdentifier
          let index = self.identifiers.indexOfObject(identifier!) // error message here
  
          //if the index is 0, return nil since we dont want a view controller before the first one
          if index == 0 {
  
              return nil
          }
  
          //decrement the index to get the viewController before the current one
          self.index = self.index - 1
          return self.viewControllerAtIndex(self.index)
  
      }
  </code></pre>
  
  <p>Main.storyboard</p>
  
  <p><img src="https://i.stack.imgur.com/Gvn5t.png" alt="enter image description here"></p>
  
  <p>Source code: <a href="https://github.com/datomnurdin/RevivalxSwiftPageViewController" rel="nofollow noreferrer">https://github.com/datomnurdin/RevivalxSwiftPageViewController</a></p>