Skip to content

Instantly share code, notes, and snippets.

@Marlunes
Created August 30, 2013 05:38
Show Gist options
  • Save Marlunes/6386612 to your computer and use it in GitHub Desktop.
Save Marlunes/6386612 to your computer and use it in GitHub Desktop.
Ignore iCloud Backup
//call this after download or after saving a file
//Example: [self addSkipBackupAttributeToItemAtURL:[NSURL fileUrlWithPath:@"your path here"]];
- (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);
}else{
NSLog(@"Success!");
}
return success;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment