AFNetworking 2.0 - mutable json

Currently my code is as follows

NSURL *URL = [NSURL URLWithString:URLForSend];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
                                     initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
 {
     NSLog(@"%@", responseObject);
     [BoxJsonDataHelper gotNewJson:responseObject];
 } failure:^(AFHTTPRequestOperation *operation, NSError *error)
 {
     NSLog(@"Request Failure Because %@",[error userInfo]);
 }];

[operation start];

But when I try to edit the dictionaries in the resulting object, I get an error about using methods that belong to the mutable dictionary, and not to the dictionary. How to do AFNetworking instead of nested mutable objects?

+4
source share
1 answer

You will report AFJSONResponseSerializerthat it needs to return mutable containers:

operation.responseSerializer = 
  [AFJSONResponseSerializer serializerWithReadingOptions: NSJSONReadingMutableContainers]

All of this is very well documented: http://cocoadocs.org/docsets/AFNetworking/2.0.0/

+23
source

All Articles