afnetworking中不支持的内容类型?

时间:2016-04-05 05:00:43

标签: ios iphone ipad afnetworking

我正在使用 AFNetworking 库从服务器发送/获取数据。在登录api中,我发送用户名&密码到服务器。但有时我从服务器获取text / html内容。为了使这项工作我使用下面的代码,但它仍然导致问题。

 NSString *url=[BASE_URL stringByAppendingString:LOGIN];
                    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
                    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                            self.txt_username.text, @"uname",
                                            self.txt_password.text, @"password", nil];
            AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializer];
            responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
            manager.responseSerializer = responseSerializer;

2 个答案:

答案 0 :(得分:0)

试试这个:

manager.responseSerializer.acceptableContentTypes = [managerObject.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];

答案 1 :(得分:0)

你也可以试试这个 -

manager.responseSerializer.acceptableContentTypes = Nil;