您好我将我的应用程序提交到App store。我读到,随着iCloud存储的推出,苹果数据存储指南几乎没有变化。我将所有用户的数据保存在应用程序文档目录中,因为文件目录的内容自动备份到iCould,如果启用,我打算将它们移动到应用程序库目录。它是否批准将内容保存到库中,考虑到苹果的数据存储指南?如果没有保存数据的位置?请帮忙。
答案 0 :(得分:0)
您有两个主要选择:
答案 1 :(得分:0)
您可以将数据放入Documents文件夹中,但在保存在documents文件夹之前,在Documents文件夹中创建一个文件夹,即temp。然后编写以下代码以不在iCloud中备份。
[[NSFileManager defaultManager] createDirectoryAtPath:temp
withIntermediateDirectories:NO
attributes:nil
error:nil];
NSURL *dbURLPath = [NSURL URLWithString:temp];
[self addSkipBackupAttributeToItemAtURL:dbURLPath];
还实现方法addSkipBackupAttributeToItemAtURL 别忘了包括
#include <sys/xattr.h>
- (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;
}