相关疑难解决方法(0)

Swift Realm Property'*'已被添加到最新的对象模型MIGRATION中

我已经将新的数组属性添加到R​​LMObject和

public class Student: RLMObject {
    dynamic var id = 0
    dynamic var name = ""
    dynamic var resultList = RLMArray(objectClassName:Result.className())
}

public class Result: RLMObject {
}
Run Code Online (Sandbox Code Playgroud)

错误日志:

由于以下错误,对象类型'Student'需要迁移: - 属性'resultList'已添加到最新的对象模型中.

尝试失败:

let configuration:RLMRealmConfiguration = RLMRealmConfiguration.defaultConfiguration()

migration.enumerateObjects(Student.className()) { oldObject, newObject in
    newObject!["resultList"] = RLMArray(objectClassName: Result.className())
}
Run Code Online (Sandbox Code Playgroud)

编辑:

  let configuration:RLMRealmConfiguration = RLMRealmConfiguration.defaultConfiguration()
    print("Realm db current version: \(configuration.schemaVersion)")
    configuration.schemaVersion = 1
    configuration.migrationBlock = {(migration:RLMMigration, oldSchemaVersion: UInt64) in
        print("Realm db migration start")
        if oldSchemaVersion < 1 {
            print("Schema version: 1 - Rename …
Run Code Online (Sandbox Code Playgroud)

migration realm swift

8
推荐指数
1
解决办法
2732
查看次数

'RLMException',原因:'由于出现以下错误,需要迁移

当我调试应用程序时,我添加了一个新属性(@property NSString *haha;),但它显示以下异常:

Terminating app due to uncaught exception 'RLMException', reason: 'Migration is required due to the following errors: 
- Property 'haha' has been added to latest object model.'
Run Code Online (Sandbox Code Playgroud)

但是当我添加忽略的属性时,它工作得很好:

+ (NSArray *)ignoredProperties {
    return @[@"thead"];
}
Run Code Online (Sandbox Code Playgroud)

为什么?谢谢。

xcode objective-c realm ios

0
推荐指数
1
解决办法
8433
查看次数

标签 统计

realm ×2

ios ×1

migration ×1

objective-c ×1

swift ×1

xcode ×1