当核心数据处理在后台时需要完整的数据保护

发布于 2024-10-03 16:46:27 字数 497 浏览 8 评论 0原文

我只是陷入了项目的中间。

我的目标是保护我的数据

我浏览过 Nickharris 博客(核心数据和企业 iPhone 应用程序 - 保护您的数据

但在结论中明确提到:

如果您的应用程序在任何后台处理中都需要您的核心数据存储,那么您无法使用数据保护。任何访问 NSFileProtectionComplete 文件的尝试都会导致异常

我在后台处理中使用核心数据。

请帮忙解决这个问题。无论如何,我想加密和保护我的数据,

谢谢, 塔里克

I am just stuck in the middle of the project.

My objective is to protect my data.

I have gone through Nickharris blog regarding (Core Data and Enterprise iPhone Applications – Protecting Your Data)

But in the conclusion it is clearly mentioned that:

If your application needs your Core Data store in any background processing, then you cannot use data protection. Any attempt to access files that are NSFileProtectionComplete will cause an exception.

And I am using core data in background processing.

Please help regarding this. I want to encrypt and protect my data anyhow

Thanks,
Tariq

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三生路 2024-10-10 16:46:27

在 iOS 5 上,您可以使用其中任何一个,但它们仍然有一个问题。

  1. NSFileProtectionCompleteUnlessOpen - 文件以加密格式存储在磁盘上,必须在设备解锁时打开。一旦打开,即使用户锁定设备,您的文件也可以继续正常访问该文件。

  2. NSFileProtectionCompleteUntilFirstUserAuthentication - 文件以加密格式存储在磁盘上,只有在设备启动后才能访问。用户首次解锁设备后,您的应用程序可以访问该文件,并且即使用户随后锁定设备也可以继续访问该文件。

来源: iOS 开发者库

On iOS 5 you can use either one, but there is still a catch for each of them.

  1. NSFileProtectionCompleteUnlessOpen - The file is stored in an encrypted format on disk and must be opened while the device is unlocked. Once open, your file may continue to access the file normally, even if the user locks the device.

  2. NSFileProtectionCompleteUntilFirstUserAuthentication - The file is stored in an encrypted format on disk and cannot be accessed until after the device has booted. After the user unlocks the device for the first time, your application can access the file and continue to access it even if the user subsequently locks the device.

Source: iOS Developer Library

左岸枫 2024-10-10 16:46:27

根据 文档 NSFileProtectionComplete 指示当应用程序处于后台(或未运行)时无法读取或写入文件。

您应该可以在应用程序运行时读取/写入 SQLite 存储,但是当它处于“后台”时您将无法访问它。

这意味着利用 iOS 后台 API 的操作,例如:

  • 推送通知
  • 后台音频/位置
  • 任务完成(后台)
  • IP 语音

将无法访问您的 SQLite 存储。但是,当应用程序运行时,您应该能够像平常一样访问 NSPersistentStoreCoordinator。我怀疑设备端测试会导致无法从后台 API 之一创建持久存储协调器。

According to the documentation NSFileProtectionComplete dictates that the file cannot be read from or written to while the application is in the background (or not running).

You should be fine to read / write the SQLite store while the application is running, however you will not have access to it while it is in the "background".

This means that operations which leverage the iOS background APIs like:

  • Push notifications
  • Background Audio / Location
  • Task completion (Background)
  • Voice Over IP

Will not have access to your SQLite store. When the app is running however you should be able to access the NSPersistentStoreCoordinator as you normally would. I suspect that a device side test would result in a failure to create the persistent store coordinator from one of the background APIs.

掩耳倾听 2024-10-10 16:46:27

在主线程中进行文件访问调用 - NSObject 上有一个非常有用的方法应该可以帮助您:)

// When you need to get the data from the file do this :
NSData *data = [self performSelectorInMainThread:@selector(getFileData:) withObject:filename waitUntilDone:YES];


// And somewhere else in your class have this method
- (NSData *)getFileData:(NSString *)filename {
    ...
    // Get data from file and return it
    ....
}

希望有所帮助。

Make your file access calls in the main thread - there's a really useful method on NSObject that should help you :)

// When you need to get the data from the file do this :
NSData *data = [self performSelectorInMainThread:@selector(getFileData:) withObject:filename waitUntilDone:YES];


// And somewhere else in your class have this method
- (NSData *)getFileData:(NSString *)filename {
    ...
    // Get data from file and return it
    ....
}

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文