作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Crashlytics 上看到许多崩溃,但无法重现应用程序启动时发生的崩溃。有谁知道如何重现以下崩溃。我已经尝试了 Github 和 stackoverflow 上的所有答案,但没有人提到如何重现这一特定崩溃。因此,如果我确实有修复程序,则无法对其进行测试,除非将修复程序投入生产,然后假设 Crashlytics 不会显示崩溃。
请帮忙。
错误:
fatal error :“尝试!”表达式意外引发错误:错误 Domain=io.realm Code=2 “无法在路径 '/var/mobile/Containers/Data/Application/03BA7C37-9852-4A01-8EF6-949E308EADCD/Documents/default.realm 处打开 Realm .lock': open() 失败: 不允许操作。"UserInfo={错误代码=2,NSFilePath=/var/mobile/Containers/Data/Application/03BA7C37-9852-4A01-8EF6-949E308EADCD/Documents/default.realm.lock,
调用代码
//passing the fileProtectionType as .none
RealmHelper.configureRealmFiles(with: .none)
示例代码
static func configureRealmFiles(with fileProtectionType: FileProtectionType) {
guard let folderPath = realm.configuration.fileURL?.deletingLastPathComponent().path else {
return
}
do {
try FileManager.default.setAttributes([FileAttributeKey.protectionKey: fileProtectionType],
ofItemAtPath: folderPath)
} catch {
logI("Realm: Couldn't change Realm file protection type")
}
}
最佳答案
Realm documentation有一些关于如何处理此错误的信息。检查他们降级文件访问属性的说明是否适合您的情况。
关于iOS崩溃: Unable to open a realm at Path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56346552/
我是一名优秀的程序员,十分优秀!