title: pageViewController viewControllerAfter/Before dataSource methods called twice
body: <p>I want to show some data in a pager-like way, so I thought using `UIPageViewController, and this is basically what I have done:</p>
  
  <pre><code>struct ModelTest {
      var number: Int
  }
  
  
  class PagerViewController: UIPageViewController, UIPageViewControllerDataSource {
  
      var currentIndex = 0
  
      var models: [ModelTest] = [
          ModelTest(number: 1),
          ModelTest(number: 2),
          ModelTest(number: 3),
          ModelTest(number: 4),
          ModelTest(number: 5)
      ]
  
      override func viewDidLoad() {
          super.viewDidLoad()
          self.dataSource = self
          if let firstModel = models.first {
              setViewControllers([ModelViewController(firstModel)], direction: .forward, animated: true, completion: nil)
          }
      }
  
      func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -&gt; UIViewController? {
          let nextIndex = currentIndex + 1
          guard nextIndex &lt; models.count else {
              return nil
          }
          self.currentIndex += 1
          return ModelViewController(models[nextIndex])
      }
  
      func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -&gt; UIViewController? {
          let previousIndex = currentIndex - 1
          guard previousIndex &gt;= 0 else {
              return nil
          }
          self.currentIndex -= 1
          return ModelViewController(models[previousIndex])
      }
  
  }
  </code></pre>
  
  <p>However, for some reason the <code>dataSource</code> methods <code>viewControllerAfter</code> and <code>viewControllerBefore</code> sometimes get called twice. Do you have any idea of why and how to solve this?</p>
  
  <p>Thanks for your help.</p>