Domain = NSCocoaErrorDomain在afnetworking 2.0中出现Code = 3840错误

时间:2015-10-13 05:52:22

标签: ios objective-c iphone json afnetworking-2

我无法在afnetworking 2.0中找到NSCocoaErrorDomain Code = 3840错误的解决方案

这是我用过的代码

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

    [manager POST:url parameters:inputs success:^(AFHTTPRequestOperation *operation, id responseObject)
    {

         NSLog(@"JSON: %@", responseObject);

    }
          failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];

这是错误获取

Error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

1 个答案:

答案 0 :(得分:0)

尝试使用AFHTTPResponseSerializer

manager.responseSerializer = [AFHTTPResponseSerializer serializer];

因为您正在使用@" text / html"的acceptableContentType,我假设您在响应调用时不需要JSON序列化程序。所以这应该适合你的情况。