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