'skip-backup'属性始终返回备份而不是跳过进程

时间:2013-06-12 12:11:29

标签: backup

我使用此方法进行不备份,输出始终成功。但是备份数据也会在ipad中备份,请帮帮我。

-(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;
}
}

以上方法我使用。请帮助我任何人。谢谢

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。我在NSUserdefault文件中首先发现NSUserdefaultplist存储数据存储的错误,以便NSUserdefault数据移除并解决问题。