简体   繁体   English

如何在不将其备份到iCloud的情况下通过我的应用程序提供演示数据?

[英]How can I provide demo data with my app without backing it up to iCloud?

I have an app in the App Store since January, that copies a database file to the "Documents" directory at first launch. 自一月份以来,我在App Store中有一个应用程序,该应用程序在首次启动时将数据库文件复制到“文档”目录中。

This database is used to store "presets", created by users. 该数据库用于存储用户创建的“预设”。 Each preset can have up to 129 photos. 每个预设最多可包含129张照片。

At start, the app comes with a "default preset", that users can use to understand and start to use the app. 在启动时,该应用程序带有一个“默认预设”,用户可以使用它来理解和开始使用该应用程序。 This preset is like a "gift" to the user, and if he doesn't want it anymore, he can just delete it. 此预设对用户来说就像是“礼物”,如果他不再想要它,则可以将其删除。

On update 2.0.2 nothing was changed in this schema, but Apple rejected my update now. 在更新2.0.2上,此架构没有任何更改,但Apple现在拒绝了我的更新。

2.23 - Apps must follow the iOS Data Storage Guidelines or they will be rejected 2.23-应用必须遵循iOS数据存储准则,否则将被拒绝

I can't figure out how I can solve this. 我不知道该如何解决。 The issue seems to be that the default preset, which Apple considers "temporary" gets backed up to iCloud. 问题似乎是苹果公司认为“临时”的默认预设已备份到iCloud。 This preset is NOT temporary. 此预设不是临时的。 It must persist, and is part of the database. 它必须持久,并且是数据库的一部分。

I also can't mark the database with the "do not back up", because this way the "presets" created by the users won't be backed up, which would be terrible. 我也无法将数据库标记为“不备份”,因为这样将不会备份用户创建的“预设”,这将是非常糟糕的。

Anybody have an idea how to solve this? 有人知道如何解决这个问题吗?

You need to flag the file to not backup to iCloud . 您需要标记文件以不备份到iCloud

Without flagging the file as such, it will be eligible to backup to iCloud. 无需将文件本身标记出来,就可以将其备份到iCloud。 Apple has recently began to enforce this. 苹果最近开始强制执行此操作。

If the app generates a lot of data, on app startup, they'll reject it. 如果应用程序生成大量数据,则在应用程序启动时,他们将拒绝该数据。 Apple's reasoning for this is that any data that can be regenerated should not be backed up to iCloud. 苹果这样做的原因是, 任何可以再生的数据都不应备份到iCloud。

To prevent this, Apple recommends: 为防止这种情况,Apple建议:

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

    NSError *error = nil;
    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
    return success;
}

Other than that blanket omission from iCloud, the only thing you're left with is separating your user generated content from your re-creatable content . 除了iCloud的全面遗漏之外,剩下的唯一事情就是将用户生成的内容与可重新创建的内容分开。

"do not back up" is a file-level attribute. “不备份”是文件级属性。 So perhaps mark only your "gift" files with that attribute? 那么也许只用该属性标记您的“礼物”文件?

Unfortunately, the guidelines are pretty clear on this -- only user generated data may be stored in the Documents directory and backed up to iCloud. 不幸的是,指南对此很明确-只有用户生成的数据可以存储在Documents目录中,并备份到iCloud。

However, it looks like you can prevent specific files from being backed up: https://developer.apple.com/library/ios/qa/qa1719/_index.html#//apple_ref/doc/uid/DTS40011342 但是,您似乎可以防止备份特定文件: https : //developer.apple.com/library/ios/qa/qa1719/_index.html#//apple_ref/doc/uid/DTS40011342

You are going to have to find a way to separate your preset data from the user's data store and mark the preset data as "do not back up" 您将必须找到一种方法来将预设数据与用户的数据存储区分开,并将预设数据标记为“请勿备份”

I faced that same problem with one of my apps. 我的一个应用程序也遇到了同样的问题。 I had to generate another version of my database and store it into the Caches folder, and mark it as not eligible for iCloud backup. 我必须生成数据库的另一个版本并将其存储到Caches文件夹中,并将其标记为不适合iCloud备份。 Then store all user generated content into another database in the documents folder, which actually gets backed up to iCloud. 然后将所有用户生成的内容存储到documents文件夹中的另一个数据库中,该数据库实际上已备份到iCloud。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS正在从我的应用程序向iCloud备份28.0KB的一些未知数据 - iOS is backing up 28.0KB of some unknown data from my app to iCloud iCloud正在备份我的应用程序的68个字节(一个plist文件),我是否需要设置一个标志以将其从icloud备份中排除? - iCloud is backing up 68 bytes of my app (a plist file), do i need to set a flag to exclude it from icloud backup? 我如何查看我的应用程序是否有iCloud数据? - How can i see if my app got iCloud data? 我可以将应用程序的SQLite数据库备份到iCloud吗? - Can I back up my app's SQLite database to iCloud? 我应该在哪里保存我想长期保存的数据和文件,以及如何阻止iCloud备份它们 - Where should I save data & files I want to keep long term, and how do I prevent iCloud from backing them up 如何组织代码以有选择地提供逻辑层的后备视图? - How can I organize my code to optionally provide a backing view for my logic layer? 如何确认已为我的应用程序启用了iCloud备份? - How can I confirm that iCloud Backup is enabled for my app? 如何为核心数据数据库启用iCloud同步? - How can I enable iCloud synchronization for my Core Data database? 我可以在没有coredata的情况下使用icloud数据吗? - Can i use icloud data without coredata? 如果我标记所有不备份后仍在iCloud上存储少量数据,我的应用是否会再次被拒绝? - Will my app be again rejected if still stores a small amount of data on iCloud after I flagged everything not to be backed up?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM