0
使用NSFileProtectionComplete加密核心數據是否可防止將數據庫同步到iTunes?使用NSFileProtectionComplete加密核心數據庫是否也可以在同步到iTunes的同時保護數據?
使用NSFileProtectionComplete加密核心數據是否可防止將數據庫同步到iTunes?使用NSFileProtectionComplete加密核心數據庫是否也可以在同步到iTunes的同時保護數據?
否。如果用戶在其設備上具有密碼,則NSFileProtectionComplete僅對核心數據文件進行加密。它不會更改設備的備份行爲。
控制備份行爲變化的IOS版本http://developer.apple.com/library/ios/#qa/qa1719/_index.html#//apple_ref/doc/uid/DTS40011342
在5.1和更高版本可以使用
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);
}