ファイルをiCloudへのバックアップ対象外にするには、AppDelegateにその旨の設定をする必要がある。
AppDelegate.m
- (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;
}
// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory
{
NSURL *pathURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
[self addSkipBackupAttributeToItemAtURL:pathURL];
return pathURL;
}
参考記事:
https://developer.apple.com/icloud/documentation/data-storage/index.html
https://developer.apple.com/library/ios/qa/qa1719/_index.html
http://iaseteam.eshizuoka.jp/e1068667.html
http://gosyujin.github.io/2013/07/18/ios-backup-restore/
http://d.hatena.ne.jp/sppsolcojp/20120323/1332493306
【iCloudの最新記事】