【问题标题】:Use preloaded database with Realm and RealmMapView using Swift 2.1使用 Swift 2.1 与 Realm 和 RealmMapView 一起使用预加载的数据库
【发布时间】:2015-12-01 16:30:07
【问题描述】:

在 Realm 中使用 Swift 2.0,是否可以指定要与 RealmMapView 一起使用的数据库?

let path = NSBundle.mainBundle().pathForResource("myDB", ofType: "realm")

var config = Realm.Configuration.defaultConfiguration
config.path = path

self.mapView.realmConfiguration = config

这目前适用于模拟器,但不适用于设备。

【问题讨论】:

    标签: realm swift2.1


    【解决方案1】:

    在设备上,应用程序的包是只读的,因此您必须设置 config.readOnly = true 以只读模式打开 Realm。

    【讨论】:

      猜你喜欢
      • 2018-08-12
      • 2020-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多