领域迁移不起作用 [英] Realm Migration not working
问题描述
我的App Store更新崩溃了,迁移得以处理,即使我看到代码块正在执行,我也遇到了以下迁移错误
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",原因:对象类型需要迁移 由于以下错误,导致"LLCachedObject": -属性'resultType'已添加到最新的对象模型中.'
'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;
}
}];
,然后我再次检查了oldSchemaVersion是否为4,并且是否正确设置了newObject [@"resultType"],这是在iOS 9上发生的,我已经一无所有,因为我已经用完了所有要检查的内容找出是什么原因造成的.
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.
推荐答案
因此问题出在,我们有另一个项目用于同一个具有Realm的同一个应用程序,我们不知道需要迁移到双方都需要处理,所以我们现在要做的是使用类子集指定每个项目使用的模型分类.
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.
有关更多详细信息,请 https://realm.io/docs/objc/latest/#class-subsets
For more details https://realm.io/docs/objc/latest/#class-subsets
这篇关于领域迁移不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!