gpt4 book ai didi

ios - NSURLAuthenticationChallenge.sender 返回 nil

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:07:13 28 4
gpt4 key购买 nike

请原谅我问题中的点符号。

我正在使用 NSURLSession 尝试登录网站。 Apple 的文档建议以这种方式处理身份验证挑战。

- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge 
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"<email>"
password:@"<password>"
persistence:NSURLCredentialPersistenceNone];
[[challenge sender] useCredential:credential
forAuthenticationChallenge:challenge];
}

问题是 [challenge sender] 返回 nil。我是否遗漏了我的设置中的某些内容?

最佳答案

不确定您是否曾经想过这一点,但您应该调用完成处理程序来代替旧的 useCredential 方法:

   completionHandler(NSURLSessionAuthChallengeUseCredential, credential);

关于ios - NSURLAuthenticationChallenge.sender 返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22123280/

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