gpt4 book ai didi

iphone - didReceiveAuthenticationChallenge 导致 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-12-03 21:23:49 31 4
gpt4 key购买 nike

如果网站不需要身份验证,我的代码可以正常工作,如果需要,则在打印“已创建凭据”后会立即出现 EXC_BAD_ACCESS 错误。我不会发布任何内容,并且此代码是直接从文档中复制的 - 知道出了什么问题吗?

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge previousFailureCount] == 0)
{
NSLog(@"received authentication challenge");

NSURLCredential *newCredential;
newCredential=[NSURLCredential credentialWithUser:@"root"
password:@"rootpassword"
persistence:NSURLCredentialPersistenceForSession];


NSLog(@"credential created");

[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];

NSLog(@"responded to authentication challenge");

}
else
{
NSLog(@"previous authentication failure");

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failure"
message:@"Website did not accept the username and password."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}

最佳答案

事实证明,这与特定网站的身份验证方法有关 - 将我要登录的网站替换为另一个网站,代码工作正常。

(我试图从 unRaid 的状态页面抓取数据,unRaid 不使用实际的网络服务器,而是使用 emhttp,所以我假设这与它有关)

关于iphone - didReceiveAuthenticationChallenge 导致 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2308677/

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