【发布时间】:2017-06-05 13:08:18
【问题描述】:
我正在尝试在我的应用程序中实现领域数据库,我有领域数据库,其中包含一些预加载的数据。我搜索了许多堆栈溢出资源,但没有取得任何成功。
到目前为止,我已经完成了以下步骤:
- 将 Realm 文件复制到我的应用程序包中
-
在应用委托中添加了以下代码:
path = Bundle.main.path(forResource: "data", ofType: "realm") var config = Realm.Configuration(fileURL: NSURL(fileURLWithPath: path!)) config.readOnly = true // Open the Realm with the configuration let realm = try! Realm(configuration: config)
但这不起作用,请提供一些解决方案。
注意:我不想迁移我的数据库。
提前致谢
【问题讨论】: