What is the recommended place to save game data if I do not want automatically to be backup to iCloud ? I am using NSUbiquitousKeyValueStore
for iCloud, and have custom logic for updates.
So I do not for iCloud backup to mess things up.
By my understanding that is: Library/Caches/
.
Because: Documents/
and Library/Preferences/
are backup to iCloud.
Am I correct ?
You shouldn't use /Library/Cache
for storing such kind of information. Look what Apple Data Storage Guidelines says:
Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory.
You can save all your data to /Documents
, just flag it so that it wouldn't copy to iCloud:
- (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);
}
return success;
}
You can use this method in your AppDelegate or wherever you create these files. Note that you can exlude from iCloud backup not only specific files, but directories too.