相关疑难解决方法(0)

AFNetworking 2.0在故障块中从代码400获取JSON

我使用AFHTTPRequestOperationManager了一个POST请求.现在我故意输入错误的信息来处理400错误代码.现在,Web服务实际上返回一个JSON消息,向用户解释他们做错了什么.我非常想让这个JSON显示消息UIAlertView.但是,失败块:

[operationManager POST:ServerURL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Success: Status Code: %d", operation.response.statusCode);
}
 failure:^(AFHTTPRequestOperation *operation, NSError *error) {
     NSLog(@"Failed: Status Code: %d", operation.response.statusCode);
 }];
Run Code Online (Sandbox Code Playgroud)

不传递响应对象,如成功块中的响应对象.那么有谁知道如何访问Web服务返回的带有400错误的JSON?在NSError *error简单地给了我Request failed: bad request (400),而不是JSON返回.

任何帮助将不胜感激,
迈克

iphone objective-c ios afnetworking afnetworking-2

7
推荐指数
2
解决办法
7889
查看次数

标签 统计

afnetworking ×1

afnetworking-2 ×1

ios ×1

iphone ×1

objective-c ×1