Realm Migration not working

三世轮回 提交于 2019-12-11 12:22:55

问题


I'm getting a crash on my App Store update, the migration is handled and even when I see the code Block is being executed I get the Following migration error

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

This is how I'm handling the Migration

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

and I double-checked that the oldSchemaVersion was 4, and newObject[@"resultType"] is being set properly, this is happening on iOS 9, I'm completely clueless as I've run out of things to checked to find out what is causing this.


回答1:


So the problem turned out being that we have another project we use for the same app that also has a Realm, we weren't aware that the migration needed to be handled in both sides, so what we are doing now is using the class subsets to specify the Model Clases that every project uses.

For more details https://realm.io/docs/objc/latest/#class-subsets



来源:https://stackoverflow.com/questions/32638291/realm-migration-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!