最近在使用 AFNetworking 时遇到了一个奇怪的问题。我有一个 PHP 后端,我正在使用 SLIM 框架。正在发生的事情的简化示例:如果我使用链接http://xxx.xxx.xx.xx/InstaAPI/hi这应该被称为:
$app->get('/hi', function() use($app) {
$app->response->setStatus(200);
echo "hiiii\n";
});
现在在我的objective-c代码中我有:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://xxx.xxx.xx.xx/InstaAPI/hi" parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
NSLog(@"ok");
NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
NSLog(@"fail");
NSLog(@"%@", operation.responseString);
}];
我在输出控制台中得到的结果是:
015-10-08 18:30:20.650 iReporter[12822:3214201] fail
2015-10-08 18:30:20.650 iReporter[12822:3214201] hiiii
不知道为什么它调用失败块。状态毕竟设置为200,所以应该没问题。有人可以给我一些指示我在这里可能做错了什么吗?