![](/img/trans.png)
[英]WKWebView iOS 10.3 crash for didReceiveAuthenticationChallenge?
[英]ios didReceiveAuthenticationChallenge status
我正在尝试通过网络服务器对用户进行身份验证,并在我的登录视图按钮触摸中调用以下方法来进行此操作。
- (void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"challenge failure %d", [challenge previousFailureCount]);
// Access has failed two times...
if ([challenge previousFailureCount] == 0)
{
//NSLog(@"desc %@",[connection description]);
NSURLCredential *cred = [[[NSURLCredential alloc] initWithUser:userName.text password:passWord.text
persistence:NSURLCredentialPersistenceForSession] autorelease];
[[challenge sender] useCredential:cred forAuthenticationChallenge:challenge];
// need to call new view on correct authentication
[connection release];
}
else {// Answer the challenge
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Authentication error"
message:@"Invalid Credentials" delegate:self
cancelButtonTitle:@"Retry"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
成功认证后是否返回任何状态,以便我可以使用该状态并传递到下一个视图,否则显示错误。
Jsut调用connectionDidFinishLoading:方法。
好的,正如我的评论中所述:
实际上,connectionDidFinishLoading:方法告诉您可以继续进行下一步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.