【发布时间】:2013-01-16 20:43:19
【问题描述】:
使用 NSFileProtectionComplete 加密核心数据是否可以防止将数据库同步到 iTunes?
【问题讨论】:
标签: iphone ipad core-data sqlite
使用 NSFileProtectionComplete 加密核心数据是否可以防止将数据库同步到 iTunes?
【问题讨论】:
标签: iphone ipad core-data sqlite
没有。如果用户的设备上有密码,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);
}
【讨论】: