2012-02-01 85 views
2

我一直无法将应用程序提交到App Store。这是因为可更新的数据库对于iCloud备份限制太大。数据库中的大部分数据都是静态的,但是一个表记录用户查看单词的时间表(这是一个词汇测验)。iOS - 如何构建符合iCloud备份规则的数据库

据我所知,我有两个或三个现实的选择。首先是将整个数据库放入Library/Cache目录。这应该被接受,因为它没有备份到iCloud。但是,也不能保证,这将在应用程序更新进行维护,每次在“让应用备份更有效”这个条目在这个网址:

http://developer.apple.com/library/IOs/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html

Files Saved During App Updates 
When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation. Files in the following directories are guaranteed to be preserved during the update process: 

<Application_Home>/Documents 
<Application_Home>/Library 
Although files in other user directories may also be moved over, you should not rely on them being present after an update. 

第二个选项是把数据转换成NSDocuments或NSLibrary目录,并将其标记为skipBackupFlag。但是,有一个问题是,此标志不适用于iOS 5.0以及之前的“如何防止将文件备份到iCloud和iTunes?”中的此条目。在

https://developer.apple.com/library/ios/#qa/qa1719/_index.html

Important The new "do not back up" attribute will only be used by iOS 5.0.1 or later. On iOS 5.0 and earlier, applications will need to store their data in <Application_Home>/Library/Caches to avoid having it backed up. Since this attribute is ignored on older systems, you will need to insure your app complies with the iOS Data Storage Guidelines on all versions of iOS that your application supports 

这意味着即使我使用了“skipBackupFlag”,我还是有一个数据库正在备份到云中的问题,我想。

因此,第三个选项,这是一个很丑陋的黑客攻击,是将数据库拆分为两个。将可更新部分放入NSLibrary或NSDocuments目录中,并将其余部分留在应用程序资源中。这将在云中存储小型可更新部分,并将其余部分留在应用程序资源目录中。问题在于,这会导致数据库无法正常分裂,并且会导致可能的性能问题,因为一次打开两个数据库。

所以,我的问题是,我对规则的解释是否正确?我将不得不选择3吗?

p.s.我注意到在我上一篇文章中引用的网址被编辑为链接而没有显示网址。我该怎么做呢?

+0

关于第二个选项 - 我认为skipBackupFlag从5.0.1开始才可用,这对于验证过程应该是一个问题,因为您基本上可以执行存储指南中所述的内容...... – Shtong 2012-02-03 20:56:50

+0

好,但你如何看待这种方式呢?它声明:“在iOS 5.0及更早版本中,应用程序需要将其数据存储在/Library/Caches中,以避免其备份。”这似乎是说它会*备份,大概是iCloud。 – 2012-02-04 02:13:30

+0

有没有人证实您可以为5.0.1设置'不备份'属性? 5.0的应用程序仍然会备份到iCloud,但苹果是否会批准该应用程序? – FishStix 2012-02-23 02:16:55

回答

0

您是否考虑过使用外部文件引用,如https://developer.apple.com/library/IOS/#releasenotes/DataManagement/RN-CoreData/_index.html中所述。具体来说,请参阅“setAllowsExternalBinaryDataStorage:”https://developer.apple.com/library/IOS/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSAttributeDescription_Class/reference.html#//apple_ref/occ/instm/NSAttributeDescription/setAllowsExternalBinaryDataStorage:。将大量数据推送到单独的文件可以帮助减少数据库大小。

+0

但CoreData外部存储中的数据以任何方式同步到iCloud,不是吗?我确实将用户映像存储在外部存储中,并且他们会同步到iCloud。 CoreData外部存储用于不在sqlite存储中存储大块数据以提升sqlite性能。 – 2012-02-03 07:42:12

+0

@KostiantynSokolinskyi好点。我提出了一种实施Jack提出的Option3的方法。 – rajagp 2012-02-03 15:39:27