我正在使用 ASIHttprequest 进行登录身份验证这是 deme 代码
我正在尝试的代码是:
[self setRequest:[ASIHTTPRequest requestWithURL:url1]];
[_request setUseKeychainPersistence:[useKeychain isOn]];
[_request setDelegate:self];
[_request setShouldPresentAuthenticationDialog:[useBuiltInDialog isOn]];
[_request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[_request setDidFailSelector:@selector(topSecretFetchFailed:)];
[_request startAsynchronous];
[request setValidatesSecureCertificate:NO];
[_request setValidatesSecureCertificate:NO];
请求失败和请求完成方法
- (IBAction)topSecretFetchFailed:(ASIHTTPRequest *)theRequest{
[responseField setText:[[request error] localizedDescription]];
[responseField setFont:[UIFont boldSystemFontOfSize:12]];
}
- (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest{
[responseField setText:[request responseString]];
[responseField setFont:[UIFont boldSystemFontOfSize:12]];
NSLog(@"Response :%@",[request responseString]);
}
- (void)authenticationNeededForRequest:(ASIHTTPRequest *)theRequest{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please Login" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil];
[alertView addTextFieldWithValue:@"" label:@"Username"];
[alertView addTextFieldWithValue:@"" label:@"Password"];
[alertView show];
}
我是 ios 新手,所以请......
在这个演示中,当我开始计时时会弹出一个警报,但是当我使用我的网络服务时,它会给出这样的响应
响应:ASIHTTPRequest:0xa846400
但不要弹出用于输入用户名和密码的警报视图
如果有任何其他更好的方式来验证登录请建议我
我想将登录名设置为rootview,成功登录后可以进入应用程序
谢谢...