Skip to content

Instantly share code, notes, and snippets.

@leecrossley
Created November 22, 2012 09:10
Show Gist options
  • Save leecrossley/4130115 to your computer and use it in GitHub Desktop.
Save leecrossley/4130115 to your computer and use it in GitHub Desktop.
Don't back up anything on iCloud, ever.
NSString* doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* lib = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version < 5.1)
{
u_int8_t b = 1;
setxattr([doc fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
setxattr([lib fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
else
{
NSURL* url = [NSURL fileURLWithPath:doc];
[url setResourceValue: [NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: Nil];
url = [NSURL fileURLWithPath:lib];
[url setResourceValue: [NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: Nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment