title: Change the screen in swift
body: <p>Following is the storyboard of my app:
  <img src="https://i.stack.imgur.com/Te9gG.png" alt="enter image description here"></p>
  
  <p>The app establishes a connection with the server on screen1 and all the communication with the server is performed in the code of this screen only. We make a request on screen4 and send it to server through the code of screen1 and app receives the response from the sever. If app gets successful response then app should show screen5, where I get error.
  I wrote different lines of code but failed. Following are line of code which I am using now:</p>
  
  <pre><code>import UIKit
  
  class logoViewController: UIViewController {
  
      @IBOutlet weak var act: UIActivityIndicatorView!
      override func viewDidLoad() {
          super.viewDidLoad()
  
          self.act.startAnimating()
  
  
  
          // Do any additional setup after loading the view.
      }
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      // syncreq function is called from the connectionViewController.
      // connectionViewController is the common class for connecting to the remote server  
      func syncreq (JSONdata: AnyObject) { // Proceesing for PRMS response
  
  
         // Getting the value from the JSON
          var Successful = self.getIntFromJSON(JSONdata as NSDictionary, key: "Successful")
  
  
          println("Value of Successful : \(Successful)")
  
          if (Successful == 0){
  
              //Method1 not worked
    // let adduser = regVC()
    // self.presentViewController(adducer, animated: true, completion: nil)
     //Method2 not worked
   //let adducer =    self.storyboard?.instantiateViewControllerWithIdentifier("registrationID") as regVC
  
          //self.navigationController?.pushViewController(adducer, animated: true)
  
             //Method3 not worked
              //let secondViewController = self.storyboard?.instantiateViewControllerWithIdentifier("registrationID") as regVC
  
              //self.navigationController?.pushViewController(secondViewController, animated: true)
              //performSegueWithIdentifier("registrationID", sender: self)
  
  
              let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
              var setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("registrationID") as RegisterViewController
              self.presentViewController(setViewController, animated: false, completion: nil)
  
          }
          else if (Successful == 1){
               let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
              var setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("mnuID") as menuViewController
              self.presentViewController(setViewController, animated: false, completion: nil)
          }
  
  
  
      }
  
      func getIntFromJSON(data: NSDictionary, key: String) -&gt; Int {
  
          let info : AnyObject? = data[key]
          // println("Value of data[key] : \(key)")
  
          if let info = data[key] as? Int {
              println("Value of value for \(key) : \(info)")
              return info
          }
  
          else {
              return 0
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code>Warning: Attempt to present &lt;project.screen5: 0x7a094790&gt; on &lt;project.ViewController: 0x79639d90&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>screenshot of error:
  <img src="https://i.stack.imgur.com/8ehdH.jpg" alt="enter image description here"></p>