相关疑难解决方法(0)

isProtectedDataAvailable 在 iOS 中始终返回 true

问题

isProtectedDataAvailable是真的,但applicationProtectedDataDidBecomeAvailable在 iOS 10~20 秒后被调用,这意味着isProtectedDataAvailable在调用回调之前应该是假的。


我正在开发iOS内置的应用程序Objective C。我已经从 AppStore 配置文件和 xcode plist 为我的应用程序启用了数据保护(当前配置为 FirstUserAuthentication)。

由于 Apple 的数据保护政策,我们的数据库在设备重启和首次解锁后几秒钟内无法访问。因此,当应用程序启动时,我使用以下逻辑限制任何数据库操作。

if([[UIApplication sharedApplication] isProtectedDataAvailable]) {
    //access data
}else {
    // wait for applicationProtectedDataDidBecomeAvailable callback
}
Run Code Online (Sandbox Code Playgroud)

我发现了一些意想不到的行为。即使[[UIApplication sharedApplication] isProtectedDataAvailable]返回true,在从我上面的代码逻辑中调用10~20秒(宽限期applicationProtectedDataDidBecomeAvailable回调作为其中的一部分后,由于实际上仍受操作系统保护,数据库被访问并失败。

有什么我想念的吗?当实际受保护的数据尚不可用时,为什么iOS返回[[UIApplication sharedApplication] isProtectedDataAvailable]值为 true?

我正在使用 Xcode 11.0,经过测试的设备 OS 13.2。

更新

对于日志中的某些情况,我发现[[UIApplication sharedApplication] isProtectedDataAvailable]返回 1 但 NSUserDefault 仍然无法访问。可能的原因是什么? …

xcode data-protection objective-c ios appdelegate

10
推荐指数
0
解决办法
960
查看次数

NSFileProtectionComplete不加密核心数据文件

我正在使用Xcode 7.3 for iOS 9.3来尝试加密Core Data文件.我正在尝试使用NSPersistentStoreFileProtectionKey并将其设置为NSFileProtectionComplete以启用加密.它由于某种原因无法工作,我总能看到应用程序生成的.sqlite文件,并浏览sqlitebrowser或iexplorer中的内容.这是我的代码:

lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
    // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.

    // Create the coordinator and store
    let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
    let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
    var failureReason = "There was an error creating or …
Run Code Online (Sandbox Code Playgroud)

encryption core-data xcode7 swift2

6
推荐指数
2
解决办法
5076
查看次数

NSFileProtectionKey的默认值

我在iOS参考文档(http://goo.gl/D5xEPQ)中找不到答案:该属性的默认值是NSFileProtectionKey多少?4个可能的值,但默认值是哪一个?

NSFileProtectionNone
NSFileProtectionComplete
NSFileProtectionCompleteUnlessOpen
NSFileProtectionCompleteUntilFirstUserAuthentication
Run Code Online (Sandbox Code Playgroud)

谢谢

data-protection nsfilemanager ios

5
推荐指数
2
解决办法
1948
查看次数