您的位置:首页 > 理论基础 > 计算机网络

关于AFHTTPRequestOperationManager跟AFURLSessionManager的区别

2015-12-14 15:46 537 查看
AFNetworking的作者kylef在回答这个问题时如此说道:

AFHTTPRequestOperationManager uses NSOperation’s under the hood, and it uses the older NSURLConnection API from Apple. It works on iOS 6 and onwards. AFURLSessionManager makes use of the newer NSURLSession API, which is only available on iOS 7. I would recommend that you use AFURLSessionManager unless you need anything that you can only do with AFHTTPRequestOperationManager such as using operations or iOS 6 support.

The AFNetworking 2.0 NSHipster article explains all of this, it’s worth checking out.

“NSURLSession is a replacement for NSURLConnection introduced in iOS 7. NSURLConnection isn’t deprecated, and likely won’t be for some time, but NSURLSession is the future of networking in Foundation, and it’s a bright future at that, addressing many of the shortcomings of its predecessor. ”– http://nshipster.com/afnetworking-2/

意思是:AFHTTPRequestOperationManager的底层使用了NSOperation,并且使用的是NSURLConnection,可支持iOS6及更新的系统版本;AFURLSessionManager使用的是更新的NSURLSession,支持iOS7.0以上系统。本人强烈建议使用AFURLSessionManager除非你要使用operations或者需要支持iOS6。

AFNetworking在cocoadocs上的官方文档

关于AFNetworking,另一个作者Mattt Thompson 如此写道

AFNetworking 2.0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: