iphone - Request with NSMutableURLRequest -
i tried make login page make user authenticate website. tried like:
nsurl *myurl = [nsurl urlwithstring:@"https://www.freelancer.com/users/onlogin.php"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:myurl cachepolicy:nsurlrequestreloadignoringlocalcachedata timeoutinterval:60]; nslog(@"ispost"); [request sethttpmethod:@"post"]; [request setvalue:usernamefield.text forkey:@"username"]; [request setvalue:passwordfield.text forkey:@"passwd"]; nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:request delegate:self]; if (!theconnection) { uialertview *alert = [[uialertview alloc] initwithtitle:@"network error" message:@"could not login!" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; [alert release]; return; }
i got erroras followed:
2012-07-07 10:09:37.354 auth[6062:f803] ispost 2012-07-07 10:09:37.357 auth[6062:f803] *** terminating app due uncaught exception 'nsunknownkeyexception', reason: '[<nsmutableurlrequest 0x68d69d0> setvalue:forundefinedkey:]: class not key value coding-compliant key username.'
can suggest me did wrong?
thanks help
why don't use like
[request setvalue:usernamefield.text forhttpheaderfield:@"username"]; [request setvalue:passwordfield.text forhttpheaderfield:@"passwd"];
hope helps you.
Comments
Post a Comment