iOS 结合 Realm 进行后台抓取

iOS Background fetch in combination with Realm

如果 iOS 后台获取正在 运行ning 同时打开应用程序,Realm 是否会阻止对数据库的访问?

我知道它在 UWP 上,因为如果我在 运行 运行应用程序时 运行 一个后台任务,我会得到一个异常“%USERPROFILE%\AppData\Local\Packages\appname\db_name.realm:加密的进程间。 ”。 iOS 上是否发生了类似的事情?

事实证明,NSFileProtection 在设备被锁定时启动。 参见 https://realm.io/docs/swift/latest/#using-realm-with-background-app-refresh

确保将数据库放在单独的文件夹中,并对文件夹设置保护。尝试更改对 Documents 文件夹本身的保护是行不通的!