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.