NSURLSessionConfiguration和NSURLRequest的相同属性? [英] same properties of NSURLSessionConfiguration and NSURLRequest?

查看:69
本文介绍了NSURLSessionConfiguration和NSURLRequest的相同属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到在官方文档中,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?

推荐答案

NSURLSessionConfiguration 对象定义行为和策略使用NSURLSession上载和下载数据时使用目的.上载或下载数据时,创建配置对象始终是您必须采取的第一步.您使用此对象来配置超时值,缓存策略,连接要求以及您打算使用的其他类型的信息与您的 NSURLSession 对象.

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.

重要:

注意

在某些情况下,此配置中定义的策略可能是被提供的 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的相同属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆