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

前端 未结 30 2992
悲哀的现实
悲哀的现实 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:40

    Whenever got error -1005 then need to call API Again.

    AFHTTPRequestOperationManager *manager = 
    [AFHTTPRequestOperationManager manager];
    [manager setSecurityPolicy:policy];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager POST:
       parameters:
        success:^(AFHTTPRequestOperation *operation, id responseObject) {
          NSLog(@“Success: %@", responseObject);
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"Error: %@", error);
          if (error.code == -1005) {
              // Call method again... 
           }
      }];
    

    You need to Add your code to call function again. MakeSure that you were call method once otherwise its call recursive loop.

提交回复
热议问题