- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
自 AFNetworking 2.0
以来,AFHTTPClient
已经消失,取而代之的是两个管理器:AFHTTPRequestOperationManager
和 AFHTTPSessionManager
.迁移指南几乎没有说明哪种情况更适合使用它们。据我所知,与 RESTful JSON API
的基本交互可以分别使用它们中的每一个来实现。
什么情况下最适合使用 RequestOperationManager
或 SessionManager
?
最佳答案
它们基本上是等价的,除了 AFHTTPSessionManager
内部使用 iOS 7/OS X 10.9 NSURLSession
,所以它不能在 iOS 6 中使用。 AFHTTPRequestOperationManager
一直存在,直到 NSURLRequest
被弃用。
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/
我在我的表格 View 中应用了这段代码。但是,我意识到第一次请求时数据加载速度会很慢。之后,如果我访问同一页面,记录将加载得更快。有什么改进第一次加载的想法吗?感谢您的帮助。 AFHTTPSessi
我正在使用 Afnetworking Framework,但每次我点击网络服务时,响应总是如下所示- Error Domain=com.alamofire.error.serialization.re
我正在尝试通过设置 HTTPAdditionalHeaders 为“Content-Type”设置默认 header 。当我查看请求 header 时,AFNetworking (v 2.0.3) 将
我正在使用 OAuth2 身份验证开发 iOS 应用程序。 我已通过身份验证,请求我的 API 没有问题,但在尝试从 protected URLS 下载某些文件时遇到问题。 我正在使用 downloa
我的应用程序使用 AFHTTPSessionManager 的子类下载信息和获取。用户可能会选择退出下载,我正试图弄清楚如何取消下载。 我遇到了这段代码: - (void) cancel {
我正在尝试使用 AFNetworking2.0 和新的 NSURLSession 类来获取一些数据。特别是我对 NSURLSessionConfiguration 的新 HTTPMaximumConn
由于我是 IOS 的新手,AFNetworking 3,0 是新的,所以我不知道如何从 AFHTTPSessionManager 中检索数据。我必须关注消息,我想返回结果 - (NSString *)
使用自定义 session 配置创建 AFHTTPSessionManager 单例子类的正确方法是什么? class DefaultSessionConfiguration: NSURLSessio
我已经坚持了一段时间,我正在使用 Youtube 的 api,但我一直收到 403 错误。我正在使用负责 OAuth2 的 Google 登录 NSString *authToken = [[NSS
我有一个文本字段,每当用户输入字符时,我都会将该字符附加到我的 url 并获得响应。 我需要取消之前的请求。例如,如果我输入 “shampoo”,我将访问服务器 7 次,我需要取消最后 6 次请求。目
我有一个应用程序,我在其中使用 session 管理器调用同步请求,在 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY
对于 AFNetworking,我遵循了创建 AFHTTPSessionManager 的应用程序特定子类的建议模式。我的看起来像这样: static NSString* Username = @""
更新 将此作为问题发布到 AFNetworking 存储库后,事实证明这实际上是我的使用问题。根据对我的问题的回复: NSURLSession retains its delegate (i.e. A
我也需要向我的服务器发送一个 post 请求。 AFHTTPRequestOperation 非常简单,只需使用: [request setHTTPBody: [requestBody dataUsi
我正在尝试使用 AFNetworking 2.0 来执行我的网络请求,但我遇到了一些奇怪的行为。我已经子类化 AFHTTPSessionManager如 suggested in the docume
我检查了 Stackoverflow 中的几篇文章(this 和 this),但没有一篇回答“如何使用 AFHTTPSessionManager 来使用基于 SOAP 的 Web 服务”。 这是不可能
我正在使用新的 afnetworking 3.0 库发出网络请求以使用 AFHTTPSessionmanager 进行登录。因此,当我执行 POST 调用并在响应中收到 401 时,会静默调用另一个网
我的应用得到静默推送,然后使用 AFNetworking 在后台做一些 http 请求,但它没有进入完整的 block ,代码是: AFHTTPSessionManager *manager = [[
当我使用 AFHTTPRequestOperationManager 时,我可以将 HTTPRequestOperationWithRequest 方法与 NSURLRequest 对象一起使用。有了
我最近遇到了一个问题,我们的一位客户的互联网连接速度非常慢,而且还使用 GroundControl。每当他们尝试加载我的应用程序时,他们都会卡在“Attemping to Connect to Ser
我是一名优秀的程序员,十分优秀!