2012-02-01 35 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