ガイドラインに示されているようNSURLIsExcludedFromBackupKey
に、フォルダ全体とその内容を に設定することで、フォルダ全体とその内容が iCloud にバックアップされないようにしようとしています。フォルダの URL にキーを設定することはできますが、そのフォルダ内に保存するすべてのデータは、その...1
0
NSURLIsExcludedFromBackupKey
これが私のコードです:
//create the directory:
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil];
NSURL *folderURL = [NSURL fileURLWithPath:path isDirectory:YES];
//prevent backup:
NSError *preventBackupError = nil;
BOOL success = [folderURL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey
error: &preventBackupError];
//this prints 1 and 1:
NSLog(@"resource values for directory: %@", [folderURL resourceValuesForKeys:@[NSURLIsExcludedFromBackupKey, NSURLIsDirectoryKey] error:nil]);
ここで、ファイル (この場合はconfig.xml
) を のサブディレクトリ内に保存してから、次のfolderURL
ようにします。
NSURL *fileURL = [NSURL fileURLWithPath:[path stringByAppendingPathComponent:@"config.xml"]];
if ([[NSFileManager defaultManager] fileExistsAtPath:fileURL.path]) {
NSLog(@"resource values for config file: %@", [configURL resourceValuesForKeys:@[NSURLIsExcludedFromBackupKey] error:nil]);
}
これは印刷しますNSURLIsExcludedFromBackupKey = 0;
this one、this one、またはthis oneなどの他のSO回答を確認しましたが、構文に違いは見られません...
私の質問は、そのキーをフォルダー内のすべてのファイルに手動で設定する必要がありますか? それとも私は何か間違ったことをしていますか?
乾杯