title: Add multiple custom UIViewControllers to UIPageViewController
body: <p>I'm trying to add UIPageViewController to my RootViewController in code. I removed storyboard file according to
  <a href="https://stackoverflow.com/questions/17234172/xcode-5-without-storyboard-and-arc">Xcode 5 without Storyboard and ARC</a>
  and adding “regular” ViewController works perfectly. I adoped methods according to UIPageViewControllerDataSource </p>
  
  <p>Also I tried to simplify logic (instead of implementing ModelController from starting PageView project I add showVCWithIndex: method to pick 1 of 3 VC from vcArray and write it to Mutable Array with 1 VC. Hope you can tell me if I was right or wrong about that.</p>
  
  <p>.m</p>
  
  <pre><code>#import "RootPageViewController.h"
  #import "ViewController0.h"
  #import "ViewController1.h"
  #import "ViewController2.h"
  
  @interface RootPageViewController ()
  
  @property (strong, nonatomic) ViewController0 *vController0;
  @property (strong, nonatomic) ViewController1 *vController1;
  @property (strong, nonatomic) ViewController2 *vController2;
  
  @property (strong, nonatomic) UIPageViewController *pageViewController;
  
  @property (strong, nonatomic) NSArray *vcArray;
  @property (strong, nonatomic) NSMutableArray *viewController;
  
  @end
  
  @implementation RootPageViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
  
      self.pageViewController.dataSource = self;
  
      _vController0 = [[ViewController0 alloc] init];
      _vController1 = [[ViewController1 alloc] init];
      _vController2 = [[ViewController2 alloc] init];
  
  
      NSUInteger index = 0;
      NSMutableArray *viewController = [NSMutableArray arrayWithObjects:[self showVCWithIndex:index], nil];
  
      [self.pageViewController setViewControllers:viewController
                                        direction:UIPageViewControllerNavigationDirectionForward
                                         animated:NO
                                       completion:nil];
  
      [self addChildViewController:self.pageViewController];
      [self.view addSubview:self.pageViewController.view];
  
      CGRect pageViewRect = self.view.bounds;
      self.pageViewController.view.frame = pageViewRect;
  
      [self.pageViewController didMoveToParentViewController:self];
  
  }
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
        viewControllerBeforeViewController:(UIViewController *)viewController
  {
      NSUInteger index = [self.vcArray indexOfObject:viewController];
      if ((index == 0) || (index == NSNotFound)) {
          return nil;
      }
  
      index--;
      return [self showVCWithIndex:index];
  }
  
  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
         viewControllerAfterViewController:(UIViewController *)viewController
  {
      NSUInteger index = [self.vcArray indexOfObject:viewController];
  
      if (index == 2 || index == NSNotFound) {
          return nil;
      }
  
      index++;
      return [self showVCWithIndex:index];
  }
  
  - (UIViewController *)showVCWithIndex: (NSUInteger)index
  {
      self.vcArray = [NSArray arrayWithObjects: _vController0, _vController1, _vController2, nil];
  
      UIViewController *currentVC = [self.vcArray objectAtIndex:index];
  
      return currentVC;
  }
  
  @end
  </code></pre>
  
  <p><strong>EDIT</strong>
  got the solution (this code works, but I'm not sure if I am 100% right)</p>