gpt4 book ai didi

ios - NSURLSessionConfiguration 和 NSURLRequest 的相同属性?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:38:14 25 4
gpt4 key购买 nike

我在官方文档中看到,NSURLSessionConfiguration 和 NSURLRequest 共享一些相同或相似的属性。比如NSURLRequestCachePolicy、networkServiceType、timeOurInterval等等,怎么来的?哪一边的优先级更高?

最佳答案

根据 Apple Documentation :

An NSURLSessionConfiguration object defines the behavior and policies to use when uploading and downloading data using an NSURLSession object. When uploading or downloading data, creating a configuration object is always the first step you must take. You use this object to configure the timeout values, caching policies, connection requirements, and other types of information that you intend to use with your NSURLSession object.

重要的是:

NOTE

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 对象覆盖。

关于ios - NSURLSessionConfiguration 和 NSURLRequest 的相同属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com