title: Remove view controller from another view controller
body: <p>I am very new to iPhone app development.<br>
  I am developing one example application for iPhone emulator using Objective-C++ and std CPP. </p>
  
  <p>I have two views in my application, on some events from CPP code i am displaying second view using following code from the first view controller. </p>
  
  <pre><code>// Defined in .h file 
  secondViewScreenController *mSecondViewScreen;
  
  // .mm file Code gets called based on event from CPP (common interface function between Objective-C++ and CPP code)
  mSecondViewScreen = [[secondViewScreenController alloc] initWithNibName:nil bundle:nil];
  [self presentModalViewController:mSecondViewScreen animated:YES];
  </code></pre>
  
  <p>I am able to see second view coming on screen, but problem is that i am unable to end/remove second view controller from first view controller.  </p>
  
  <p>How can i remove second view controller from first view controller using second view controller's pointer or using any other method. </p>
  
  <p>To remove second view i have following code in second view controller file, which gets called on button click event of second view. </p>
  
  <pre><code>// In .mm of second view controller. 
  - (IBAction)onEndBtnClicked:(UIButton *)sender
  {
     [self dismissModalViewControllerAnimated:NO];
     [self.navigationController popViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>Above code works perfectly, when i click on the seconds view's end button it removes the second view controller from the screen and navigets to first view, how can i use same code to remove second view from the first view controller.   </p>
  
  <p>I tied to use <code>NSNotificationCenter</code> to send event from first view to second view to call the function <code>onEndBtnClicked</code> but it is not working.</p>
  
  <p>What is the proper way of doing it? </p>
  
  <p>OSX version: 10.5.8 and Xcode version: 3.1.3</p>