AFNetworking 2.0 - 可变的JSON

4

我的代码目前是这样的

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];

但是,当尝试编辑接收到的对象中的字典时,会出现一个错误,提示使用属于可变字典而非普通字典的方法。如何让AFNetworking使用嵌套的可变对象呢?


1个回答

23

谢谢,我从文档中误解了它应该是默认设置。 - Yoav Schwartz
1
顺便说一下,这个选项优化了一些内存处理,因为它不会将可变容器复制到不可变容器中。而且为了返回可变的叶子节点:manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions: NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves]; - Borzh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接