Since the AFNetworking 2.0
the AFHTTPClient
has been vanished in the favour of two managers: AFHTTPRequestOperationManager
and AFHTTPSessionManager
. The migration guide says pretty much nothing about the cases when each of them is preferable to use. As far as I can see the basic interaction with a RESTful JSON API
can be implemented using each of them separately.
What are the most suitable cases to use either RequestOperationManager
or SessionManager
?
They are basically equivalent, except that the AFHTTPSessionManager
uses internally the iOS 7/OS X 10.9 NSURLSession
, so it can't be used in iOS 6. AFHTTPRequestOperationManager
is there until NSURLRequest
gets deprecated.
So to recap: in order to support the new NSURLSession APIs as well as the old-but-not-deprecated-and-still-useful NSURLConnection, the core components of AFNetworking 2.0 are split between request operation and session tasks. AFHTTPRequestOperationManager and AFHTTPSessionManager provide similar functionality, with nearly interchangeable interfaces that can be swapped out rather easily, should the need arise (such as porting between iOS 6 and 7).
Note that are a few differences between both. AFHTTPSessionManager returns NSURLSessionDataTask objects, which are not NSOperations. That means it's harder to enqueue them and establish dependencies between requests.