I am using iOS 7's new NSURLSessionDataTask
to retrieve data as follows:
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:
request completionHandler:
^(NSData *data, NSURLResponse *response, NSError *error) {
//
}];
How can I increase the time out values to avoid the error "The request timed out"
(in NSURLErrorDomain
Code=-1001
)?
I have checked the documentation for NSURLSessionConfiguration but did not find a way to set the time out value.
Thank you for your help!
NSURLSessionConfiguration includes the property timeoutIntervalForRequest:
to control the timeout interval. There is also timeoutIntervalForResource for the timeout after the request is initiated.
In SWIFT 3.0, You need to use
In swift 3. timeout 15 seconds.
In case Swift developer coming here
to do this, you need to use
For Swift 4:
The timeoutIntervalForRequest is for all tasks within sessions based on this configuration. The timeoutIntervalForResource is for all tasks within sessions based on this configuration.
ObjC
Swift
What docs say
timeoutIntervalForRequest
andtimeoutIntervalForResource
specify the timeout interval for the request as well as the resource.Based on NSURLSessionConfiguration Class Reference