Swift Login app -
i'm trying make new login app xcode. had been written code goes wrong it.
the code looks correct when debugging skip "task" end of code , ? here code:
@ibaction func mybutton(sender: anyobject) { //login button let username = input.text! let userpassword = password.text! if ( username.isempty || userpassword.isempty) { return } //send data user server side let myurl = nsurl(string: "http://servertest.cf/store.php?loginuser=test%40home.com&loginpassword=123456789") let myrequest = nsmutableurlrequest(url: myurl!) myrequest.httpmethod = "post" let poststring = "email=\(username)&password=\(userpassword)"; myrequest.httpbody = poststring.datausingencoding(nsutf8stringencoding) let task = nsurlsession.sharedsession().datataskwithrequest(myrequest) { data , response , error in if error != nil { println("error\(error)") self.mylabel.text = "wrong user name" } var err : nserror? var json = nsjsonserialization.jsonobjectwithdata(data, options: .mutablecontainers , error: &err) as? nsdictionary if let parsejson = json { var resultvalue:string = parsejson["status"] as! string! println("result\(resultvalue)") if(resultvalue == "success" ) { var storyboard: uistoryboard = uistoryboard(name: "main", bundle: nil) var vc: uinavigationcontroller = storyboard.instantiateviewcontrollerwithidentifier("secondviewcontroller") as! uinavigationcontroller self.presentviewcontroller(vc, animated: true, completion: nil) } } } task.resume() }
the closure queued queue , run in thread. add breakpoint inside closure if want run line-by-line.
Comments
Post a Comment