我试图制作一个登录页面以使用户对网站进行身份验证。我试过类似的东西:
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;
}
我得到一个错误如下:
2012-07-07 10:09:37.354 Auth[6062:f803] ispost
2012-07-07 10:09:37.357 Auth[6062:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSMutableURLRequest 0x68d69d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key username.'
谁能建议我做错了什么?
谢谢你的帮助