I am creating a NSURLSession object with timeoutIntervalForRequest
configuration = 120 seconds. After this I am creating a NSURLSessionDataTask
object and calling the method dataTaskWithRequest:completionHandler
. Here one input parameter is a NSURLRequest
. Again while I create a NSURLRequest, I can specify a some of parameters like timeout, cachePolicy etc. But these were already mentioned while I created NSURLSessionConfiguration
. So if I use different values for a NSURLRequest
, will those values override NSURLSessionConfiguration
values?
Will NSURLRequest timeout value overrides NSURLSessionConfiguration timeoutIntervalForRequest value?
Asked
Active
Viewed 415 times
2

Advaith
- 1,087
- 3
- 12
- 31
2 Answers
4
In short, YES.
According to Apple's document:
In some cases, the policies defined in this configuration may be overridden by policies specified by an NSURLRequest object provided for a task. Any policy specified on the request object is respected unless the session’s policy is more restrictive. For example, if the session configuration specifies that cellular networking should not be allowed, the NSURLRequest object cannot request cellular networking.

Brian
- 30,156
- 15
- 86
- 87
0
My recollection is that yes, the value in the request takes precedence over the session's value. With that said, I'm not 100% certain, so I would try it and make sure, assuming it actually matters.

dgatwood
- 10,129
- 1
- 28
- 49