xcode AFNetworking 错误域代码=-999 ? 但工作正常吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16780489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:26:03  来源:igfitidea点击:

AFNetworking Error Domain Code=-999 ? But works fine?

iosxcodejsonnetworkingafnetworking

提问by glesage

I'm getting a strage error from AFNetworking even the though the request seems to work fine (as the change actually happens on the site).

我从 AFNetworking 收到一个奇怪的错误,尽管请求似乎工作正常(因为更改实际上发生在网站上)。

Error Domain=NSURLErrorDomain Code=-999 "The operation couldn't be completed 
(NSURLErrorDomain error -999.)" UserInfo=0x1fd4a080
{NSErrorFailingURLKey=http://gcm.greenlightdispatch.com/services/json/}

The strange thing is that it returns this error but it actually doesn't have a problem completing the request (on the server, the information passes through just fine and all).

奇怪的是,它返回了这个错误,但实际上完成请求没有问题(在服务器上,信息传递得很好)。

AFHTTPClient *httpClient = [[[AFHTTPClient alloc] initWithBaseURL:url] autorelease];
[httpClient postPath:@"" parameters:[NSDictionary dictionaryWithDictionary:params]
             success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"Success: %@", [responseObject objectFromJSONData]);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error.description);
}];

Thanks for the help

谢谢您的帮助

回答by Patrick Tescher

This has been answered many times before. The operation is being canceled which is why you get that error.

这个问题之前已经回答过很多次了。正在取消操作,这就是您收到该错误的原因。

What to do about an NSURLErrorDomain -999?

如何处理 NSURLErrorDomain -999?