问题
I'm about to upgrade AFNetworking
from 1.x to 3.x. My question is what is the different between AFHTTPSessionManager
and AFURLSessionManager
? and when to use each? Which one support both XML
and JSON
request and response? Thanks
回答1:
You generally use AFHTTPSessionManager
if you want to do GET
or POST
requests that might include preparation of JSON or x-www-formurlencoded
requests or parsing of complex responses. You can get away with AFURLSessionManager
if you're doing very simple requests for which you don't need any of the additional AFHTTPSessionManager
capabilities.
Bottom line, AFHTTPSessionManager
is just a subclass of AFURLSessionManager
with some richer creation of complex requests and/or parsing of complex responses. Based upon your question (parsing XML and JSON responses), AFHTTPSessionManager
is what you want to use.
来源:https://stackoverflow.com/questions/38602385/afnetworking-3-x-what-is-the-different-between-afhttpsessionmanager-and-afurlses