我在AFN3.1.0中暂停NSURLSessionDataTask后仍然超时

时间:2017-05-10 08:56:21

标签: ios afnetworking nsurlsessiondatatask

我使用follow方法初始化NSURLSessionDataTask

- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;

然后调用setDataTaskDidReceiveResponseBlocksetDataTaskDidReceiveDataBlock将数据写入文件。 然后我调用suspend但是在timeoutInterval之后我得到了带有超时错误的completionHandler。

关于暂停的文件: /* * Suspending a task will prevent the NSURLSession from continuing to * load data. There may still be delegate calls made on behalf of * this task (for instance, to report data received while suspending) * but no further transmissions will be made on behalf of the task * until -resume is sent. The timeout timer associated with the task * will be disabled while a task is suspended. -suspend and -resume are * nestable. */

我想知道如何暂停任务,以及为什么我这样调用暂停它不起作用

1 个答案:

答案 0 :(得分:0)

这也发生在我身上。我做了几次测试,似乎AFN没有任何内容,你可以暂停NSURLSessionDownloadTask,但不能暂停NSURLSessionDataTask。我不知道原因。

更新:我发现了这篇文章:NSURLSessionTask. Suspend does not work