title: Pop UIViewController using Custom Segue?
body: <p>I am following <a href="https://stackoverflow.com/a/26478478/394736">this</a> answer to "release" my previous view controller in a UINavigationController.</p>
  
  <p>It works fine however the popping part is the code I am having difficult in getting to work. Basically my app works like this. It starts on a main menu (View 1) then it pushes to View 2 and I use the custom push segue to get to View 3. Now I want to use a different custom segue for popping now to go from View 3 to View 2. However, by using the code below, it pops to View 1 very quickly and then eventually pushes to View 2. It looks like the view controller transition is unnatural and I am just looking to achieve the usual pop transition just instead by using a custom segue to "release" the source view controller. </p>
  
  <p>This is my code I am using now to no avail:</p>
  
  <pre><code>- (void)perform {
      // Grab Variables for readability
      UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
      UIViewController *destinationController = (UIViewController*)[self destinationViewController];
      UINavigationController *navigationController = sourceViewController.navigationController;
  
      // Get a changeable copy of the stack
      NSMutableArray *controllerStack = [NSMutableArray arrayWithArray:navigationController.viewControllers];
      // Replace the source controller with the destination controller, wherever the source may be
      [controllerStack addObject:destinationController];
  
      // Assign the updated stack with animation
      [navigationController setViewControllers:controllerStack animated:YES];
  }
  </code></pre>
  
  <p>Is there something I am doing wrong here?</p>