- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 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/
方法 -isFileReferenceURL 是在 NSURL 类上定义的,但我不知道这个方法是什么。我认为这决定了 URL 是否指向实际文件,但事实并非如此。即使文件存在,它也会返回NO。手册上说只
给定一个本地 URL 地址,例如 index.html 现在我需要使用UIWebView在iPad中加载它。我按照以下步骤操作: 创建 NSURL NSURL *url = [NSURL fileUR
我正在尝试将 NSString(文档目录中文件的路径)转换为 NSURL,但 NSURL 始终为空。这是我的代码: NSURL *urlToPDF = [NSURL URLWithString:app
我有一个将属性定义为 NSURL 的对象: @interface fcpElement : NSObject @property (copy) NSString* elementName; @prop
我正在尝试使用 swift 和 firebase 构建聊天应用程序并收到此错误:下面是代码:我仍然不明白哪里出了问题!!我也在使用 JSQMessageViewController。 func sen
我尝试将 deviceToken 附加到 webView loadRequest 之前的 URL,以便我可以使用 GET 值PHP 脚本。我的问题是,保存 deviceToken 值的函数 didFa
我有 2 个 [NSURL] 数组,它们具有相同的元素,但顺序不同。我正在尝试使用 array1 的索引路径来获取成员,并在另一个数组中检测成员的索引路径。 我不知道我是否可以检测到成员在 NSURL
我有一个文件(假设是一个 PDF)存储在我的 macOS Cocoa 应用程序的磁盘上。我有包含此文件路径的 NSURL。 我目前正在使用 NSView 向用户显示此文件存在,其中包含一个显示文件名的
我为 Swift 2 升级了我的代码,这里出现错误: 无法使用 (fileURLWithPath: NSURL) 类型的参数列表调用类型 NSURL 的初始化程序 代码如下: let dirP
我正在尝试将 NSURL * _Nullable 转换为不可为空。你们有没有人知道我该怎么做? 这里是一些上下文: 我正在尝试使用 ios-oauthconsumer ,我正在尝试初始化一些对象: s
我最近在比较两个 NSURL 并将一个 NSURL 与 NSString(这是一个 URL 地址)进行比较时遇到了一个问题,情况是我从某个地方得到了一个 NSURLRequest,我可能知道也可能不知
我必须解析一个 JSON API 的返回,我已将 URL 转换为一个字符串,然后我将它传递给 NSURL,但在 NSLog 中它显示为 nil。这是我的代码, NSString *urlstring=
我有一个名为 downloadedPhotoURLs 的变量,其类型为 [NSURL]?。 我正在尝试分配返回类型 [NSURL] 的函数的结果(非可选)。 我在分配时解开变量downloadedPh
我有一个网址 http://www.hdwallpapers.in/walls/honda_v4_concept_widescreen_bike-wide.jpg 我要提取的文件名为“honda_v4
我有一个 NSURL: 服务器调用?x=a&y=b&z=c 获取 y 值最快、最有效的方法是什么? 谢谢 最佳答案 更新: 自 2010 年撰写本文以来,Apple 似乎已经为此目的发布了一套工具。请
我在 SO 上看到了很多关于 NSURL 和 NSString 之间转换的问题。它们都涉及使用 NSString *path = [myURL AbsoluteString]; 或 NSString
-[NSURL startAccessingSecurityScopedResource] 状态的文档: You must balance every call to the startAccessi
我在 SO 上看到了很多关于 NSURL 和 NSString 之间转换的问题。它们都涉及使用 NSString *path = [myURL AbsoluteString]; 或 NSString
我在 SO 上看到了很多关于 NSURL 和 NSString 之间转换的问题。它们都涉及使用 NSString *path = [myURL AbsoluteString]; 或 NSString
我在 SO 上看到了很多关于 NSURL 和 NSString 之间转换的问题。它们都涉及使用 NSString *path = [myURL AbsoluteString]; 或 NSString
我是一名优秀的程序员,十分优秀!