title: Button Action to Controller and Back Swift
body: <p>I am new to programming Swift and I have a Button with a Target to a function:</p>
  
  <pre><code>func buttonAction(sender:UIButton!)
  {
      self.window.rootViewController.presentViewController(FirstViewController(), animated: true, completion: nil);
  
  }
  </code></pre>
  
  <p>Yet, I have a Button on the FirstView (of FirstViewController) and yet I want to go back to the MainView (of MainViewController) and I get the error Code:</p>
  
  <pre><code>2014-07-30 00:53:44.545 FifthTry[30275:833440] Warning: Attempt to present
  &lt;_TtC8FifthTry19FirstViewController: 0x787b5470&gt; on &lt;_TtC8FifthTry18MainViewController:
  0x799802d0&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>What is wrong?</p>