微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – “不备份”属性是否适用于“库/缓存”中的数据

Apple的 data storage guidelines声明如下:

2) Data that can be downloaded again or regenerated should be stored
in the /Library/Caches directory.

……(强调我的):

4) Use the “do not back up” attribute for specifying files that should remain on device,even in low storage situations. Use this attribute
with data that can be recreated but needs to persist even in low
storage situations for proper functioning of your app or because
customers expect it to be available during offline use. This attribute
works on marked files regardless of what directory they are in
,
including the Documents directory. These files will not be purged and
will not be included in the user’s iCloud or iTunes backup. Because
these files do use on-device storage space,your app is responsible
for monitoring and purging these files periodically.

Apple链接到该主题的更多detailed discussion页面没有提及任何有关阻止缓存数据被清除的属性内容.

所以,有人知道“不备份”属性是否实际上对于放置在/ Library / Caches中的项目“不备份和不删除”,或者文件仍然需要存储在应用程序的Documents目录中以确保当设备空间不足时,它们不会被删除

解决方法

我在iPhone 5 iOS 7.1.1上进行了快速测试:

我将一些文件放到“/ Library / Caches”(NSCachesDirectory)并使用NSURLIsExcludedFromBackupKey属性标记它们.然后我以正常方式将更多大文件放到同一目录中.

然后我通过使用相机应用程序拍摄长视频来制作低磁盘空间警告.警告后,标记为“不备份”的文件未从缓存中删除,但其他文件是!所以,这个属性确实起作用,并且尽管它的名称做了两个不同的事情 – 从备份中排除并保留在低空间警告时被清除.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐