我在使用 Realm (v1.0.2) 进行迁移期间出现内存泄漏。我的代码如下所示:
let config = Realm.Configuration(
schemaVersion: 1,
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
migration.enumerate(MyClassRealm.className(), { (oldObject, newObject) in
newObject!["remoteId"] = 0
newObject!["deleted"] = false
newObject!["dirty"] = true
newObject!["updated"] = 0
})
}
})
// Tell Realm to use this new configuration object for the default Realm
Realm.Configuration.defaultConfiguration = config
// Now that we've told Realm how to handle the schema change, opening the file
// will automatically perform the migration
do {
let _ = try Realm()
} catch {
TSLog.error(error as NSError)
}
你知道有什么问题吗?