joshuahornby10
joshuahornby10

Reputation: 4302

kCFErrorDomainCFNetwork error -1005 AFNetworking

I have a singleton class:

+(id)sharedClient
{
static HackerNewsClient *__instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    NSURL *url = [NSURL URLWithString:@"http://node-hnapi.herokuapp.com"];
    __instance = [[HackerNewsClient alloc] initWithBaseURL:url];
});

return __instance;
}

And in a controller I am calling this like so:

 [[HackerNewsClient sharedClient]GET:@"/news"
                         parameters:nil
                            success:^(NSURLSessionDataTask *task, id responseObject) {

                                NSArray *posts = [self parseEpisodeJSONData:responseObject];
                                completion(posts);
                            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                NSLog(@"ERROR: %@", error);
                            }];

The url this creates is http://node-hnapi.herokuapp.com/news which is a valid and working url. But the error message returned is

2014-07-08 08:51:15.942 hn[27435:1627947] ERROR: Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0x10ba2bf70 {NSErrorFailingURLStringKey=http://node-hnapi.herokuapp.com/news, NSErrorFailingURLKey=http://node-hnapi.herokuapp.com/news, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x10ba22ff0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"}

I can't work out what would be causing this issue. Thanks

Upvotes: 5

Views: 13615

Answers (2)

iCyberPaul
iCyberPaul

Reputation: 650

Look in the CFNetworkErrors header files for CFNetwork Framework.

In Xcode navigate to

ProjectName > Frameworks > CFNetwork.framework > Headers > CFNetworkErrors.h

Upvotes: 3

Saleh AlDhobaie
Saleh AlDhobaie

Reputation: 311

this error always appeared when the connection fails .. if your connection work fine just try to restart the iPhone simulator spicily with iPhone 6 simulator ...!

check link : NSURLConnection GET request returns -1005, "the network connection was lost"

Upvotes: 10

Related Questions