【发布时间】:2016-08-02 17:05:26
【问题描述】:
我想在我的应用程序中使用带有隐式数据的领域文件(在单独的项目中,我用数据填充它,然后复制它。两个应用程序中的模型对象相同)。
在模拟器上,一切都很好。但是当我在 iPhone 上运行应用程序时,Xcode 会抛出错误。
let path = (NSBundle.mainBundle().pathForResource("testLevel", ofType: "realm"))!
let config = Realm.Configuration(path: path)
let realm = try! Realm(configuration: config) // also tried try! Realm(path: path)
当我打印 .realm 文件的路径时,一切都很好 - 没有零 -
不知道如何处理它,有什么想法吗? (iOS9)
错误:
致命错误:“试试!”表达式意外引发错误:错误 Domain=io.realm Code=2 "不允许操作" UserInfo={Error 代码=2, NSFilePath=/var/containers/Bundle/Application/7DE151B5-42EE-45C6-8245-B57683EA64D8/sneakers.app/testLevel.realm, NSLocalizedDescription=不允许操作}: 文件 /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, 第 54 行
【问题讨论】: