【问题标题】:Does encrypting core database using NSFileProtectionComplete protects data even during sync to iTunes as well?即使在同步到 iTunes 期间,使用 NSFileProtectionComplete 加密核心数据库是否也能保护数据?
【发布时间】:2013-01-16 20:43:19
【问题描述】:

使用 NSFileProtectionComplete 加密核心数据是否可以防止将数据库同步到 iTunes?

【问题讨论】:

    标签: iphone ipad core-data sqlite


    【解决方案1】:

    没有。如果用户的设备上有密码,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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-28
      相关资源
      最近更新 更多