Error Domain=NSURLErrorDomain Code=-1005 “The network connection was lost.”

前端 未结 30 2993
悲哀的现实
悲哀的现实 2020-11-22 05:51

I have an application which works fine on Xcode6-Beta1 and Xcode6-Beta2 with both iOS7 and iOS8. But with Xcode6-Beta3, Beta4, Beta5 I\'m facing network issues with iOS8 but

30条回答
  •  名媛妹妹
    2020-11-22 06:45

    I had the same problem. I don't know how AFNetworking implements https request, but the reason for me is the NSURLSession's cache problem.

    After my application tracking back from safari and then post a http request, "http load failed 1005" error will appear. If I stop using "[NSURLSession sharedSession]", but to use a configurable NSURLSession instance to call "dataTaskWithRequest:" method as follow, the problem is solved.

    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    config.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    config.URLCache = nil;
    self.session = [NSURLSession sessionWithConfiguration:config];
    

    Just remember to set config.URLCache = nil;.

提交回复
热议问题