lau*_*cel 1 iphone json ios afnetworking
我正在使用
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
}
Run Code Online (Sandbox Code Playgroud)
一切正常,除了一种情况,当我收到400状态代码的响应,和JSON(有效,我已检查)包含有关此错误的一些信息,我可以使用浏览器看到.但是JSONRequestOperationWithRequest调用成功块,JSON并且响应是零.什么可能导致这个?
如果requestOperation在完成后出现关联错误,则会调用失败.出错的原因包括响应具有不正确的内容类型,没有可接受的状态代码(默认情况下为2XX范围,但可以更改AFHTTPRequestOperation +addAcceptableStatusCodes:),或者处理下载的数据时出错.这是保证的行为.
作为failure块的一部分,您可以在400响应中获取JSON对象,并且您可以获得nilJSON中的JSON success.这些都与AFNetworking的工作方式一致.
| 归档时间: |
|
| 查看次数: |
1768 次 |
| 最近记录: |