iOS数据存储指南拒绝

Cri*_*682 5 iphone appstore-approval ios

我的应用被拒绝,因为它必须遵循iOS数据存储指南.我已经在stackoverflow上阅读了一些答案,我已经阅读了一些博客......我知道我的问题,在第一次应用程序启动时我复制1个sqlite数据库并解压缩文档文件夹中的一些图像.问题是icloud自动填充文件目录中的任何文件.我不需要在我的应用程序中使用icloud,但我的文件必须保留在文档文件夹中,因为它们是我的应用程序的基础数据,必须是persit(缓存文件夹或临时文件夹不是正确的解决方案).所以我读到了一个标志,我可以逐个文件设置以禁止备份:

[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];

我还读过这个方法只适用于高于5.0.1的ios,在另一个中它将被简单地忽略(我已经将我的ios部署目标设置为4.3)...如果我使用这种方法我的应用程序将再次被拒绝因为较旧的ios设备备份不受管理?如果是,有一个cross-iosversion方法来设置NSURLIsExcludedFromBackupKey?

编辑我很抱歉icloud不存在于ios 5.0之前,所以我认为问题只涉及版本5.0和5.0.1之间的差异,我错了?

Cri*_*682 3

我已经通过此方法传递了将存储在文档文件夹中的所有文件。

尝试这个

-(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{

const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
if (&NSURLIsExcludedFromBackupKey == nil) {
    // iOS 5.0.1 and lower
    u_int8_t attrValue = 1;
    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
    return result == 0;

}
else {
    // First try and remove the extended attribute if it is present
    int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
    if (result != -1) {
        // The attribute exists, we need to remove it
        int removeResult = removexattr(filePath, attrName, 0);
        if (removeResult == 0) {
            NSLog(@"Removed extended attribute on file %@", URL);
        }
    }

    // Set the new key
    NSError *error = nil;
    [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
    return error == nil;
}
}
Run Code Online (Sandbox Code Playgroud)

我在 Stack Overflow 中找到了这个方法: