1

I init NSURLSessionDataTask with follow method

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

then call setDataTaskDidReceiveResponseBlock and setDataTaskDidReceiveDataBlock to write data to file. and then I call suspend but the after the timeoutInterval I get completionHandler with timeout error.

the document about suspend: /* * 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. */

I want to know how to suspend the task,and why I call suspend like this it does not work

Suhit Patil
  • 11,748
  • 3
  • 50
  • 60
Rachel
  • 11
  • 3

1 Answers1

0

It also happened to me. I did several tests, it seems that there is nothing with AFN, you can suspend a NSURLSessionDownloadTask, but not NSURLSessionDataTask. I have no idea about the reason.

Update:I found this post: NSURLSessionTask. Suspend does not work

Community
  • 1
  • 1
Robert
  • 470
  • 4
  • 12