gpt4 book ai didi

objective-c - 在 AFHTTPRequestOperation Manager 和 AFHTTPSessionManager 之间进行选择时的建议

转载 作者:太空狗 更新时间:2023-10-30 03:18:04 26 4
gpt4 key购买 nike

AFNetworking 2.0 以来,AFHTTPClient 已经消失,取而代之的是两个管理器:AFHTTPRequestOperationManagerAFHTTPSessionManager .迁移指南几乎没有说明哪种情况更适合使用它们。据我所知,与 RESTful JSON API 的基本交互可以分别使用它们中的每一个来实现。

什么情况下最适合使用 RequestOperationManagerSessionManager

最佳答案

它们基本上是等价的,除了 AFHTTPSessionManager 内部使用 iOS 7/OS X 10.9 NSURLSession,所以它不能在 iOS 6 中使用。 AFHTTPRequestOperationManager 一直存在,直到 NSURLRequest 被弃用。

Check here for more info :

So to recap: in order to support the new NSURLSession APIs as well as the old-but-not-deprecated-and-still-useful NSURLConnection, the core components of AFNetworking 2.0 are split between request operation and session tasks. AFHTTPRequestOperationManager and AFHTTPSessionManager provide similar functionality, with nearly interchangeable interfaces that can be swapped out rather easily, should the need arise (such as porting between iOS 6 and 7).

请注意,两者之间存在一些差异。 AFHTTPSessionManager 返回 NSURLSessionDataTask 对象,它们不是 NSOperations。这意味着很难将它们排入队列并在请求之间建立依赖关系。

关于objective-c - 在 AFHTTPRequestOperation Manager 和 AFHTTPSessionManager 之间进行选择时的建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19313731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com