Skip to content

Instantly share code, notes, and snippets.

@fannheyward
Created January 23, 2014 01:15
Show Gist options
  • Save fannheyward/8570937 to your computer and use it in GitHub Desktop.
Save fannheyward/8570937 to your computer and use it in GitHub Desktop.
exclude_file_from_icloud_backup.m
#include <sys/xattr.h>
if (!&NSURLIsExcludedFromBackupKey) {
// iOS <= 5.0.1
const char *filePath = [[URL path] fileSystemRepresentation];
const char *name = "com.apple.MobileBackup";
u_int8_t value = 1;
int result = setxattr(filePath, name, &value, sizeof(value), 0, 0);
} else {
// iOS >= 5.1
NSError *error = nil;
[URL setResourceValue:@YES
forKey:NSURLIsExcludedFromBackupKey
error:&error];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment