【发布时间】:2013-05-17 15:01:20
【问题描述】:
我正在使用
NSMutableURLRequest *request = [self requestWithMethod:@"GET" path:@"paths/" parameters:params];
AFJSONRequestOperation *jsonRequest = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request success:^(NSURLRequest *request,
NSHTTPURLResponse *response, id JSON) {
// something to do here in case of success
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON
{
// and something there in case of failure
}
一切正常,除了在一种情况下,当我收到带有 400 状态 代码的响应和包含有关此错误的一些信息的 JSON(有效,我已检查)时,如我可以看到使用浏览器。
但是JSONRequestOperationWithRequest 调用成功块,而JSON 和响应为零。
这是什么原因造成的?
【问题讨论】:
-
如果您收到 400 状态代码,则应调用失败块。 (我检查了 AFNetworking 源代码)
-
实际上在其他情况下调用失败块,只有在这种情况下调用成功块
标签: iphone ios json afnetworking