title: pop To View Controller
body: <p>I am new to coding objective-C and am trying to use pop to <code>viewController</code>. To do this when a button is tapped i use</p>
  
  <pre><code>[self.navigationController popToViewController:(what goes here) animated:YES];
  </code></pre>
  
  <p>I know its a <code>UIViewController*</code> that goes there but I am wondering where do I declare this and what code would I use to declare it.</p>
  
  <p>My basic storyboard is I have 4 view controller A,B,C,D and A is the root which pushed to B which pushes to C which pushes to D, my button is on D and I am trying to pop back to B. The object at index method won't work because its doesn't always go <code>A-&gt;B-&gt;C-&gt;D</code> sometimes it goes <code>A-&gt;C-&gt;B-&gt;D</code> so </p>
  
  <pre><code>[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex:2] animated:YES];
  </code></pre>
  
  <p>So that doesn't work.</p>
  
  <p>Thanks for the help in advance. Sorry if this question is too basic.</p>