NSURLErrorDomain 错误代码 -1005 [英] NSURLErrorDomain Error Code -1005
问题描述
我正在学习斯坦福大学的 CS193p 课程(我不是斯坦福大学的学生,我只是想学习),作业编号 5,我们必须使用对 Flickr api 的调用从 Flickr 获取图像.我只是想下载图片列表并将它们打印到控制台,但我收到了代码为 -1005 的 NSURLErrorDomain.我打印出来的错误信息如下:
I'm working on the CS193p coursework from Stanford (I'm not a Stanford student I'm just trying to learn), assignment number 5, where we have to get images from Flickr using calls to the Flickr api. I'm only trying to download a list of the pictures and print them out to the console, but I'm getting an NSURLErrorDomain with code -1005. The error message I am printing out is below:
error: Error Domain=NSURLErrorDomain Code=-1005 操作无法完成.(NSURLErrorDomain 错误 -1005.)" UserInfo=0x7f9449c83df0 {NSErrorFailingURLStringKey=https://rest/api_key=4f9c3155b34836b2ac15318d98b93f3a?method=flickr.places.getTopPlacesList&place_type_id=7&format=json&nojsoncallback=1&api_key=4f9c3155b34836b2ac15318d98b93f3a, NSErrorFailingURLKey=https://api.flickr/flickrPlaces.getTopPlacesList&place_type_id=7&format=json&nojsoncallback=1&api_key=4f9c3155b34836b2ac15318d98b93f3a, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x7f9449c7fca0 "操作无法完成.(kCFErrorDomainCFNetwork 错误 -1005.)"}
error: Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0x7f9449c83df0 {NSErrorFailingURLStringKey=https://api.flickr.com/services/rest/?method=flickr.places.getTopPlacesList&place_type_id=7&format=json&nojsoncallback=1&api_key=4f9c3155b34836b2ac15318d98b93f3a, NSErrorFailingURLKey=https://api.flickr.com/services/rest/?method=flickr.places.getTopPlacesList&place_type_id=7&format=json&nojsoncallback=1&api_key=4f9c3155b34836b2ac15318d98b93f3a, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x7f9449c7fca0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"}
Flickr API 调用发生在以下方法中:
The Flickr API call is happening in the following method:
NSURLSession *urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];
NSURLSessionDownloadTask *downloadTask = [urlSession downloadTaskWithURL:[FlickrFetcherHelper URLforTopPlaces] completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
NSArray *topPlaces;
if (!error) {
topPlaces = [[NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:location] options:0 error:&error] valueForKeyPath:FLICKR_RESULTS_PLACES];
}
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(topPlaces, error);
});
}];
[downloadTask resume];
我正在使用 xCode 6,不确定这是否与问题有关.相同的代码几天前还在工作,我认为我没有更改任何会搞砸的东西,但它显然有.
I'm using xCode 6, not sure if that has anything to do with the problem. The same code was working a couple days ago, and I don't think I changed anything that would mess it up, but it clearly has.
推荐答案
您使用的是 iOS8(例如 iPhone 6)模拟器吗?如果是这样,请尝试更换为 iPhone 5s.我遇到了同样的问题并切换了我的模拟器,并且一切正常.我在阅读以下反馈后尝试了这个:https://github.com/AFNetworking/AFNetworking/issues/2314
Are you using the iOS8 (iPhone 6 for example) simulator? If so, try changing to iPhone 5s. I was having the same problem and switched my simulator and all worked well again. I tried this after reading the following feedback: https://github.com/AFNetworking/AFNetworking/issues/2314
这篇关于NSURLErrorDomain 错误代码 -1005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!