title: sign in page doesn't work swift 2
body: <p>I've created a sign in page using this  tutorial:</p>
  
  <p><a href="https://dipinkrishna.com/blog/2015/07/ios-login-signup-screen-tutorial-swift-2-xcode-7-ios-9-json/" rel="nofollow">https://dipinkrishna.com/blog/2015/07/ios-login-signup-screen-tutorial-swift-2-xcode-7-ios-9-json/</a> </p>
  
  <p>Made changes on my need tested with web service on tutorial working fine but wen I try my web service it doesn't login but in xcode log I have data that I want. I want to show them in other page that uses a different class.</p>
  
  <p>Login view controller codes:</p>
  
  <pre><code>do {
              let post:NSString = "username=\(username)&amp;password=\(password)"
  
              NSLog("PostData: %@",post);
  
              let url:NSURL = NSURL(string:"http://www.k-pay.ir/home/loginpost")!
  
              let postData:NSData = post.dataUsingEncoding(NSASCIIStringEncoding)!
  
              let postLength:NSString = String( postData.length )
  
              let request:NSMutableURLRequest = NSMutableURLRequest(URL: url)
              request.HTTPMethod = "POST"
              request.HTTPBody = postData
              request.setValue(postLength as String, forHTTPHeaderField: "Content-Length")
              request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
              request.setValue("application/json", forHTTPHeaderField: "Accept")
  
  
              var reponseError: NSError?
              var response: NSURLResponse?
  
              var urlData: NSData?
              do {
                  urlData = try NSURLConnection.sendSynchronousRequest(request, returningResponse:&amp;response)
              } catch let error as NSError {
                  reponseError = error
                  urlData = nil
              }
  
              if ( urlData != nil ) {
                  let res = response as! NSHTTPURLResponse!;
  
                  NSLog("Response code: %ld", res.statusCode);
  
                  if (res.statusCode &gt;= 200 &amp;&amp; res.statusCode &lt; 300)
                  {
                      let responseData:NSString  = NSString(data:urlData!, encoding:NSUTF8StringEncoding)!
  
                      NSLog("Response ==&gt; %@", responseData);
  
                      //var error: NSError?
  
                      let jsonData:NSDictionary = try NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary
  
  
  
                      let buildingid: NSString = jsonData.valueForKey("buildingid") as! NSString
                      let buildingname: NSString = jsonData.valueForKey("buildingname") as! NSString
                      let unitOwnerName: NSString = jsonData.valueForKey("unitOwnerName") as! NSString
                      let unitMostajerName: NSString = jsonData.valueForKey("unitMostajerName") as! NSString
                      let SakenMoteqayyer: NSString = jsonData.valueForKey("SakenMoteqayyer") as! NSString
                      let SakenSabet: NSString = jsonData.valueForKey("SakenSabet") as! NSString
                      let BedehiMalek = (jsonData["BedehiMalek"] as? NSString) ?? 0
                      let Tedad: NSString = jsonData.valueForKey("Tedad") as! NSString
                      let Metragh: NSString = jsonData.valueForKey("Metragh") as! NSString
                      let unitId: NSString = jsonData.valueForKey("unitId") as! NSString
  </code></pre>
  
  <p>And Code I wrote in home view controller:</p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(true)
  
      let prefs:NSUserDefaults = NSUserDefaults.standardUserDefaults()
      let isLoggedIn:Int = prefs.integerForKey("ISLOGGEDIN") as Int
      if (isLoggedIn != 1) {
          self.performSegueWithIdentifier("goto_login", sender: self)
      }else {
  
          Tedad.text = "\(Tedad)"
          Metragh.text = "\(Metragh)"
          buildingid.text = "\(buildingid)"
          buildingname.text = "\(buildingname)"
          unitId.text = "\(unitId)"
          unitMostajerName.text = "\(unitMostajerName)"
          unitOwnerName.text = "\(unitOwnerName)"
          SakenMoteqayyer.text = "\(SakenMoteqayyer)"
          SakenSabet.text = "\(SakenSabet)"
          BedehiMalek.text = "\(BedehiMalek)"
  
      }
  
  }
  </code></pre>
  
  <p>}
  I've connected some labels in my home view controller.</p>
  
  <p>Why sign in doesn't work and how can I place data in an other class?</p>
  
  <p>------UPDATE------
  Added this code signs in well but not showing datas in labels well:</p>
  
  <pre><code>let prefs:NSUserDefaults = NSUserDefaults.standardUserDefaults()
                      prefs.setObject(buildingid, forKey: "buildingid")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(buildingname, forKey: "buildingname")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(unitOwnerName, forKey: "unitOwnerName")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(unitMostajerName, forKey: "unitMostajerName")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(SakenMoteqayyer, forKey: "SakenMoteqayyer")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(SakenSabet, forKey: "SakenSabet")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(BedehiMalek, forKey: "BedehiMalek")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(Tedad, forKey: "Tedad")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(Metragh, forKey: "Metragh")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
                      prefs.setObject(unitId, forKey: "unitId")
                      prefs.setInteger(1, forKey: "ISLOGGEDIN")
                      prefs.synchronize()
  
  
                      self.dismissViewControllerAnimated(true, completion: nil)
  </code></pre>
  
  <p>Labels are shown like <a href="http://i.stack.imgur.com/OOQJx.png" rel="nofollow">this</a></p>