问题描述
我看到在官方文档中,NSURLSessionConfiguration和NSURLRequest共享一些相同或相似的属性.例如,NSURLRequestCachePolicy,networkServiceType,timeOurInterval等.结果如何?哪一方的优先级更高?
I see that in official documentation, NSURLSessionConfiguration and NSURLRequest share some same or similar properties. For example, NSURLRequestCachePolicy, networkServiceType, timeOurInterval etc. How come? Which side is in higher priority?
推荐答案
每 Apple文档:
重要:
在某些情况下,此配置中定义的策略可能是被提供的 NSURLRequest
对象指定的策略覆盖完成一项任务.遵守在请求对象上指定的任何策略除非会议的政策更具限制性.例如,如果会话配置指定不应将蜂窝网络允许, NSURLRequest
对象无法请求蜂窝网络.
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.
因此,基本上, NSURLSessionConfiguration
在 NSURLSession
处设置属性,这些属性可以由 NSURLRequest
对象覆盖.
So, essentially, NSURLSessionConfiguration
sets the properties at NSURLSession
which can be overridden by NSURLRequest
object.
这篇关于NSURLSessionConfiguration和NSURLRequest的相同属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!