ios - 核心数据和数据保护

标签 ios swift xcode core-data data-protection

所以我正在开发一个应用程序,它在本地使用 CoreData 框架存储用户信息。这些信息可能很敏感,所以我在考虑如何保护存储在数据库中的信息。在 Xcode 仪表板的功能选项卡下,我找到了这个数据保护开关:

有人知道这是怎么回事吗?如果我打开开关,Xcode 会自动编码我的 CoreData 文件吗?或者如何对我的 CoreData 文件实现这种保护? 感谢您的时间和耐心。谢谢!

最佳答案

根据 Apple 文档,当用户为设备设置有效密码时,数据保护会自动启用。系统在幕后加密和解密您的内容。这些过程是自动的并且硬件加速。 但我们仍然可以通过使用 nonecompletecompleteUnlessOpencompleteUntilFirstUserAuthentication 以编程方式设置文件保护级别选项。 p>

let options = [NSMigratePersistentStoresAutomaticallyOption:true,
                           NSInferMappingModelAutomaticallyOption:true,
                           NSPersistentStoreFileProtectionKey: FileProtectionType.complete] as [String : Any]
            try persistantStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options)

引用这个link了解有关不同类型期权的更多信息。

关于ios - 核心数据和数据保护,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41253189/

相关文章:

ios - 设置 UI 时 Swift 在 `init` 中看似奇怪的行为

ios - CallKit - "Touch to return to call"未删除

xcode - Alamofire 响应属性列表

objective-c - 更新到 Xcode 6 后的神秘错误

IOS:stringByReplacingOccurrencesOfString 不起作用

ios - UIViewController 拒绝正确定位

ios - Xcode 10.1 : Pods not compiling when running UITest

即使已获得许可,iOS 麦克风选项也不在应用程序设置中

ios - 如何以人类可读的形式显示 OptionSet 值?

Xcode 无法连接到成员(member)中心