Prevent app from backing up documents folder?

后端 未结 2 1471
长发绾君心
长发绾君心 2020-12-25 08:59

I\'m trying to prevent my app backing up files to iCloud but have become completely confused and a little lost.

-EDIT-

I\'ve updated this to reflect the chan

2条回答
  •  醉话见心
    2020-12-25 09:45

    - (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;
    }
    
    NSURL *documentURLWithExtension = [documentURL URLByAppendingPathExtension:extensionType];
    

    pass this "documentURLWithExtension" to this function

    [self addSkipBackupAttributeToItemAtURL:documentURLWithExtension];
    

提交回复
热议问题