1

There were some changes in new version of AFNetworking (2.0).

I'm now confused with all new functions and I would like to know which class/method would be best for getting JSON data from http post request ? Should I build some singleton class like the one that was used in previous versions of AFNetworking (AFNetworking (AFJSONRequestOperation) convert to AFHTTPClient) ?

Thanks.

Community
  • 1
  • 1
Želja Huber
  • 337
  • 5
  • 14

1 Answers1

3

If you are starting like this:

NSURL *baseURL = [NSURL URLWithString:AFNetworkingTestsBaseURLString:@"http://httpbin.org/"];
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];
AFHTTPRequestOperation *operation = [manager POST: ....
[operation start]; 

and you read the docs of AFHTTPRequestOperationManager, you see that the manager already defaults to AFJSONRequestSerializer, AFCompoundResponseSerializer, so you don't have to do anything special.

Jano
  • 62,815
  • 21
  • 164
  • 192
  • Oh, I see, so that would be usual way ? Since I tried and there are plenty of classes which can achieve the same and I always get the json result right. – Želja Huber Oct 03 '13 at 16:45
  • iOS 7 supports NSURLConnection and NSURLSession based networking, so you have a [couple of managers](http://i.stack.imgur.com/VXHip.png) with two similar alternate flows, both using the serializers and multipart support. – Jano Oct 03 '13 at 17:13