title: "Presenting view controllers on detached view controllers is discouraged" message when presenting modal
body: <p>I have a navigation controller and root view. Then in that root view, I pushed a view there I have to click to watch the content, if logged in, if not logged it, it would open a modal view controller with the below code.</p>
  
  <pre><code>        var vc = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
          self.tabBarController!.presentViewController(vc, animated: true, completion: nil)
  </code></pre>
  
  <p>In viewdidload() i have a nsnotification so that I could get notified when user loggedinback from login modal</p>
  
  <pre><code> NSNotificationCenter.defaultCenter().addObserver(self, selector: ("didDismissSecondViewController:"), name: "SecondViewControllerDismissed", object: nil)
  </code></pre>
  
  <p>In Login controller after all work I wrote the below code</p>
  
  <pre><code> self.dismissViewControllerAnimated(true, completion: {NSNotificationCenter.defaultCenter().postNotificationName("SecondViewControllerDismissed", object: nil, userInfo: nil)});
  </code></pre>
  
  <p>So in my first view controller I wrote the below code</p>
  
  <pre><code>func didDismissSecondViewController(sender: AnyObject)
  {
      NSLog("Called ns notifications")
      dispatch_async(dispatch_get_main_queue(),{
  
          let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          if Reachability.isConnectedToNetwork() == true {
  let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          let vc : VideoPlayViewController = storyboard.instantiateViewControllerWithIdentifier("video") as! VideoPlayViewController
          vc.movieUrl = self.movieURL
          NSLog("URL:- \(self.movieURL)")
          let navigationController = UINavigationController(rootViewController: vc)
  
          self.presentViewController(navigationController, animated: true, completion: nil)
  
          }
          else
          {
  
           var alert = UIAlertView(title: "No Internet connection", message: "Please ensure you are connected to the Internet. Connect to internet and and choose any sorting option to reload.", delegate: self,  cancelButtonTitle: "Cancel")
                  alert.addButtonWithTitle("Ok")
                  alert.show()
  
  
          }
  
  
      })
  
  }
  </code></pre>
  
  <p>However, when it tries to present the view controller after dismiss login controller, it shows "Presenting view controllers on detached view controllers is discouraged" Error and it crashed.</p>