AFNetworking 3.x what is the different between AFHTTPSessionManager and AFURLSessionManager?

半腔热情 提交于 2019-12-05 23:23:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!