gpt4 book ai didi

ios - NSURL 错误代码 1022

转载 作者:可可西里 更新时间:2023-11-01 03:36:40 24 4
gpt4 key购买 nike

我有一个 RSS 阅读器应用程序,它有一个解析器。它运行良好,直到 iOS 9 beta。每当我尝试加载数据时,都会收到错误代码 1022。这是我建立连接的代码:

- (void)parseRssFeed:(NSString *)url withDelegate:(id)aDelegate {
[self setDelegate:aDelegate];

responseData = [NSMutableData data];
NSURL *baseURL = [NSURL URLWithString:url];


NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];

[[NSURLConnection alloc] initWithRequest:request delegate:self];
}

错误处理程序:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSString * errorString = [NSString stringWithFormat:@"Unable to download XML data (Error code %i )", [error code]];

UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}

我不确定 iOS 8 和 9 之间发生了什么变化,但出于某种原因,该应用程序不再有效。任何帮助将不胜感激!

最佳答案

因此,问题与 ATS(应用程序传输安全)有关,这是 iOS 9 中的一项新功能,可在连接到 URL 之前检查其真实性。由于我不关心所连接网站的安全性,因此我完全禁用了 ATS。这可以通过将以下代码添加到应用程序的 info.plist 文件来完成:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

关于ios - NSURL 错误代码 1022,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32532020/

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