0

In AFN 2.0 there is a property to set the content type and serialize the response. I used the following code:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];

But in Restkit, I cant serialize the response to text/html since they are using AFN 1.x and the code above works on 2.x. How can I solve this issue?

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping method:RKRequestMethodAny pathPattern:nil keyPath:nil statusCodes:nil];
NSURL *url = [NSURL URLWithString:URL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]];
A7madev
  • 728
  • 3
  • 10
  • 18

1 Answers1

1

You should use serialization provided by RestKit itself: [RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:@"text/html"];

dispatchMain
  • 1,617
  • 2
  • 18
  • 30