问题描述
我即将将AFNetworking
从1.x升级到3.x.我的问题是AFHTTPSessionManager
和AFURLSessionManager
有什么区别?以及何时使用它们?哪一个同时支持XML
和JSON
请求和响应?谢谢
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
推荐答案
如果要执行可能包含JSON或x-www-formurlencoded
请求准备或解析的GET
或POST
请求,通常使用AFHTTPSessionManager
复杂的响应.如果您要执行非常简单的请求而又不需要任何其他AFHTTPSessionManager
功能,则可以使用AFURLSessionManager
.
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.
最重要的是,AFHTTPSessionManager
只是AFURLSessionManager
的子类,具有更丰富的复杂请求创建和/或复杂响应解析功能.根据您的问题(解析XML和JSON响应),AFHTTPSessionManager
是您要使用的内容.
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.
这篇关于AFNetworking 3.x AFHTTPSessionManager和AFURLSessionManager有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!