【发布时间】:2016-07-26 19:43:58
【问题描述】:
当应用程序在后台调用 addPersistentStoreWithType 时,我的 sqlite 文件有时不可用,我收到此错误:
[Model createPersistentStoreCoordinatorWithStoreURL:] line 387 $ sqlite 加密状态 NSFileProtectionCompleteUntilFirstUserAuthentication 错误:错误域=NSCocoaErrorDomain 代码=256“操作无法完成。(Cocoa 错误 256。)”UserInfo=0x1560e540 {NSUnderlyingException=授权被拒绝,NSSQLiteErrorDomain =23}
我发现这是因为文件仍然受到保护(默认为NSFileProtectionCompleteUntilFirstUserAuthentication,因此在用户重启后第一次解锁设备后,受保护的数据可用)。我觉得这行为不正确,因为我有大量的崩溃,我无法想象有很多人在野外重启后仍然锁定他们的设备。
因此,我现在正在添加我的持久存储协调器,并像这样调整配置
NSDictionary *options = @{
NSMigratePersistentStoresAutomaticallyOption : @YES,
NSInferMappingModelAutomaticallyOption : @YES,
NSPersistentStoreFileProtectionKey : NSFileProtectionNone
};
问题:
- 如果设备被锁定,这是否能确保文件在后台也可用?
- 如果我更改
NSPersistentStoreFileProtectionKey,这会破坏 sqlite(/内部数据)吗? - 我没有在数据库中存储敏感数据,但是,您在使用
NSFileProtectionNone时是否发现安全问题?
【问题讨论】:
标签: ios objective-c core-data persistent-storage nspersistentstore