Return to main view controller when app goes in background
<p>In my app I have tree view controllers, when the app enters background I want the app to get back to the main view controller. My app is a single application without <code>UINavigationController</code>. </p>

<p>I know that I have to implement this inside:</p>

<pre><code>func applicationWillResignActive(application: UIApplication) {

}
</code></pre>

<p>but I am not sure how to tell the app to return to the main view controller.</p>

<p>How can I do this?</p>

<p>UPDATE</p>

<p>I have made a small <a href="https://drive.google.com/open?id=0B9zuA_b7fzjJQTJ4d0w3Z3l4TTQ" rel="nofollow">example</a> that takes the app to the main view controllers when enters background. 
The first Time it goes background the app works fine after I start to get a warning. How can I resolve the warning?  </p>