title: How to Remove a Previous ViewController
body: <p>I am a student and pretty new to programming. I am trying to learn Objective-C/Swift in my spare time. I made a game using spriteKit with swift that has multiple menus/scenes. </p>
  
  <p>I am trying to transition from one view controller to another. To do this I used this code:</p>
  
  <pre><code>@IBAction func PlayButtonPressed(sender: AnyObject) {
      let playStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
      let vc : UIViewController = playStoryboard.instantiateViewControllerWithIdentifier("playGame") as UIViewController
      self.presentViewController(vc, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>This works for transitioning to the new VC scene, however, I believe the previous VC is still in the stack and takes up memory, slowing down my program. </p>
  
  <p>I've read on some other posts that you can use the navigation controller to remove VC. However, I do not have a navigation controller; only view controllers. I've seen some stuff about <code>removeFromParentViewController()</code> and  <code>view.removeFromSuperview()</code>, but I don't really know how to implement it. Other than that I did not find an answer that I was looking for.</p>
  
  <p>So the question I am asking is how do I remove the previous VC from the stack? Any help would be a appreciated! (would prefer the help to be in swift, but Objective-C would help also) Thank you in advance!</p>
  
  <p><strong>note for reference:</strong> I believe in Objective-C my code would look something like this:</p>
  
  <pre><code>-(IBAction) PlayButtonPressed: (id) sender {
      UIStoryboard *playStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
      UIViewController *vc = [playStoryboard instantiateViewControllerWithIdentifier:@"playGame"];
      [self presentViewController:vc animated:YES completion:nil];
  }
  </code></pre>