title: How to dismiss a viewcontroller within another ViewController?
body: <p>Let say I have view controllers named <strong>A</strong>,<strong>B</strong>,<strong>C</strong>,<strong>D</strong>,<strong>E</strong> I open these<code>ViewConrollers</code>one after the other in presentModel way. When I am in <code>ViewController</code> <strong>E</strong> I want to open another <code>ViewController</code> <strong>F</strong> in presentModel way. In that <strong>F</strong> <code>ViewController</code> I have a back button. When I click on that It should dismiss the <strong>F</strong> and show the <strong>A</strong> <code>ViewController</code>. But now when it dismissse shows <strong>E</strong>. How can I dismiss all other viewcontrollers except the <strong>A</strong> when I click the back button of <strong>F</strong></p>
  
  <p>Please help me. Thanks</p>
  
  <p><strong>UPDATED</strong></p>
  
  <pre><code>-(IBAction)dismisthis:(id)sender{
  
  
  UIViewController *dismissingViewController = self.presentingViewController;
  while (dismissingViewController.presentingViewController != nil &amp;&amp; [dismissingViewController isKindOfClass:[FrontViewController class]]) {
      dismissingViewController = self.presentingViewController;
  }
  
  
  
  
  [dismissingViewController dismissViewControllerAnimated:NO completion:NULL];
  </code></pre>