When transferring large amounts of data, you are encouraged to set the value of this property to YES. Doing so lets the system schedule those transfers at times that are more optimal for the device. For example, the system might delay transferring large files until the device is plugged in and connected to the network via Wi-Fi. The default value of this property is NO.
For transfers started while your app is in the background, the system always starts transfers at its discretion—in other words, the system assumes this property is YES and ignores any value you specified.
从 NSURLConnection 到 NSURLSession http://objccn.io/issue-5-4/ 介绍discretionary属性时,提到的:
在苹果文档中还指出,当文件非常大时,这个属性也会做出相应的推迟,必须要插上电源以后,才会继续。虽然原文没有,但是,是不是把这一点也写上比较好?
我的遭遇是,大概40多分钟的视频,会出现延迟下载。但是具体多大的文件,我也不清楚…… 以上是自己的遭遇,可能实际环境中,还有部分其他代码的影响,但是使用allowsCellularAccess为NO时的确是可以的。
还有就是当在后台时,该属性会自动设置认为是YES,而不是根据我们自行设置的值。不知道我有没有理解对,感觉这个也写上比较好。