gpt4 book ai didi

ios didReceiveAuthenticationChallenge状态

转载 作者:行者123 更新时间:2023-11-29 13:40:41 27 4
gpt4 key购买 nike

我正在尝试通过网络服务器对用户进行身份验证,并在我的登录 View 按钮触摸中调用以下方法来执行此操作。

- (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];



}

}

成功验证后是否有任何状态返回,以便我可以使用该状态并传递到下一个 View ,否则显示错误。

最佳答案

只需调用 connectionDidFinishLoading: 方法。

关于ios didReceiveAuthenticationChallenge状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9258686/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com