领域迁移不起作用

Realm Migration not working

我的 App Store 更新出现崩溃,迁移已处理,即使我看到代码块正在执行,我也收到以下迁移错误

'RLMException', reason: 'Migration is required for object type 'LLCachedObject' due to the following errors: - Property 'resultType' has been added to latest object model.'

这就是我处理迁移的方式

[migration enumerateObjects:LLCachedObject.className
                      block:^(RLMObject *oldObject, RLMObject *newObject) {
                          if (oldSchemaVersion < 5) {
                              newObject[@"resultType"] = kLLResultTypeBrief;
                          }
                      }];

我仔细检查了 oldSchemaVersion 是 4,并且 newObject[@"resultType"] 设置正确,这是在 iOS 9 上发生的,我完全无能为力,因为我'已经 运行 没有东西需要检查以找出导致此问题的原因。

所以问题原来是我们有另一个项目用于同一个应用程序,它也有一个领域,我们不知道迁移需要在双方都处理,所以我们现在正在做的正在使用 class 子集来指定每个项目使用的模型类。

更多详情https://realm.io/docs/objc/latest/#class-subsets