How do I create a directory that will not be backed up automatically by iCloud. (I do not want to backup this directory or any files in this directory or subdirectories.)
I am creating a directory 'my_dir' as follows:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *libraryPath =
[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES) firstObject];
myDirPath = [libraryPath stringByAppendingPathComponent:@"my_dir"];
[fileManager createDirectoryAtPath:myDirPath
withIntermediateDirectories:NO
attributes:nil error:nil];
Is there a simple attribute that I can set? What can I do here to easily mark the directory 'my_dir' so that it is never backed up by iCloud?
I understand that this solution can be used to go back through existing files and directories:
NSURL *guidesURL = [NSURL fileURLWithPath:guidesPath]; [guidesURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:NULL]
The question is, is there a better way to do this by setting an attribute on the directory at directory creation time that applies to the directory and all subfiles?
To be clear is there an attribute that I can use with this call: [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
To exclude the directory from automatic backup?