Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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