码迷,mamicode.com
首页 > 移动开发 > 详细

IOS Data Storage

时间:2015-05-05 19:48:57      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:ios   ios data storage   

    应用又被拒绝了,原因是IOS Data Storage  

为了区分清楚sandbox里边各个目录的作用,我去看了下apple文档,sandbox目录介绍

总结下:

Documents:存放用户产生的数据,比如用户下载的视频图书,浏览记录等。但是对于位于Documents中可在生成或可重新下载的资源,必须标记为不能通过iTunes恢复的类型(NSURLIsExcludedFromBackupKey)(意思是说文件太大了,又是个动态的,不需要备份)。翻译的比较挫,看下官方的原话,自己体会下:

Remember that files in Documents/ and Application Support/ are backed up by default. You can exclude files from the backup by calling -[NSURL setResourceValue:forKey:error:] using the NSURLIsExcludedFromBackupKey key. Any file that can be re-created or downloaded must be excluded from the backup. This is particularly important for large media files. If your application downloads video or audio files, make sure they are not included in the backup.

具体方法:

//标记文件夹不可从iTunes恢复

            [[NSURL URLWithString:resource] setResourceValue:@(YES)

                                                                                    forKey:NSURLIsExcludedFromBackupKey

                                                         error:nil];



Library/Preferences:我们不需要自己创建文件进去,这个目录一般是程序使用NSUserDefaults存储数据的地方。支持iTunes恢复。


Library/Caches: 这个目录可以用来存储任何文件,包括用户的数据。IOS2.2之后caches就不在支持iTunes恢复,并且会在iTunes恢复时被清空,IOS5之后系统会在硬盘紧张时清空该目录。所以用来存储用户数据需要谨慎,最好是放到Documents。  


Tmp: 在程序运行的时候可用来存放临时文件,文件不再需要时需要自己手动移除,当然系统在程序没有运行时也会定期清空,不支持iTunes恢复。



PS:用到的同学请点个赞吧



IOS Data Storage

标签:ios   ios data storage   

原文地址:http://blog.csdn.net/growinggiant/article/details/45503679

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!