苹果存储指南的方式给我带来了更多问题,因为我从 Documents 目录维护的大部分数据(文件、数据库和某种与应用程序相关的东西).最近我将一个二进制文件上传到应用程序商店,它被拒绝了,苹果向我提供了一份报告 根据这一点,我将更改我的代码,如下所示
The way apple storage guidelines is creating more problem for me because most of the data i am maintaining from the Documents directory (files,dataBase and some kind of app related stuff).Recently i uploaded a binary file to the app store it was rejected and apple provided me a report according to this point i am going to change my code as a below
- (NSString *)applicationDocumentsDirectory {
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSURL *pathURL= [NSURL fileURLWithPath:documentPath];
[self addSkipBackupAttributeToItemAtURL:pathURL];
return documentPath;
}
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
我的问题:
1.我可以直接对文档目录使用 addSkipBackupAttributeToItemAtURL: 方法来禁止我在文档目录中的所有文件的 iCloud 备份.
1.can i use addSkipBackupAttributeToItemAtURL: method directly to the documents directory to privent the iCloud backup for my all files in the documents directory.
2.上面提到的代码足以让我的应用在应用商店中获得批准,以防我的最后一个二进制文件由于不备份"属性而被拒绝,因为我的文档目录中不包含不备份"属性.
2.Above mentioned code is enough for my app to be approve in app store in case my last binary rejected due to "do not back up" attribute not included for my documents directory.
您应该能够将此属性设置为文件夹,以避免备份完整的文件夹.
You should be able to set this attribute to a folder in order to avoid backup of the complete folder.
但请注意,对完整的 Documents 文件夹执行此操作可能不是一个好方法.首先,这将造成您的应用程序没有备份内容的情况,因此在手机恢复时应用程序将处于原始状态.我也可以想象这不是苹果想要的"方式,因此可能导致应用程序被拒绝(总是猜测).如果可能,我会在 Document 目录中为您的非备份内容创建一个子文件夹,并将所有内容放在那里(如果您已经在商店中拥有此应用程序的版本,这可能需要一些迁移代码).
Note however that it might noch be a good approach to do this to the complete Documents folder. First of all this will create a situation where you're app has no backed-up content thus on a restore of the phone the App will be in vanilla state. I could also imagine that this just is not the way "as Apple intended" and thus could lead to rejection of the app (always a guesswork). If possible, I would create a subfolder for your non-backed-up content in the Document directory and put everything there (this might need some migration code though if you already have a version of this app on the store).
请注意,存储指南确实允许在 Documents 目录中存储用户创建/不可重新创建的内容,您只需标记下载的内容等不能放入 Caches 目录的内容(例如,如果用户预计此内容可以离线使用).
Note that the storage guidelines do allow storage of user-created / non-recreatable content in the Documents directory and you only have to mark things like downloaded content etc. that you cannot put in the Caches directory (for example if the user expects this content to be available offline).
这篇关于从 iCloud 中的应用程序备份阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!