核心数据迁移 - 找不到用于迁移的映射模型

发布于 2024-10-24 17:02:41 字数 660 浏览 2 评论 0原文

我按照这里找到的指南进行操作: http://www.timisted.net/blog/archive/core-data-迁移/ 但当我使用新模型启动应用程序时,不断收到“找不到用于迁移的映射模型”。我已经在 xcode 3 和 xcode 4 中尝试过多次,但永远无法让它工作。

目前我的选项设置为:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
    nil];

我之前为推断选项设置了“是”,但随后它只是进行迁移,而没有调用我需要迁移的自定义策略,我认为这是因为它之前也找不到映射模型。

我的地图模型没有被采纳有什么原因吗?我通过对照 SVN 版本检查了之前的模型,再次确认没有对它进行任何更改。

谢谢。

I followed the guide found here:
http://www.timisted.net/blog/archive/core-data-migration/
but keep getting "Can't find mapping model for migration" when I start up the app with the new model. I've tried it in xcode 3 and xcode 4, multiple times, but can never get it to work.

Currently my options are set to:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
    nil];

I had YES set for the infer option before but then it was just migrating without calling my custom policies that I need to migrate, which I assume is cause it couldn't find the mapping model before either.

Any reason my mapping models aren't getting picked up? I've double checked that no changes were made to the previous model by checking it against the SVN version of it.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏见 2024-10-31 17:02:41

事实证明,映射模型需要成为 .xcdatamodeld 包的一部分,这在 xcode 4 中是不可能实现的。有了它,它就可以很好地工作。

注意:我的映射文件再次停止工作,我发现它在光盘上为 0KB,因此我必须再次重新创建它,之后工作正常。我很快就提交了,看看它是否会再次消失。问题是 Xcode 4 对它进行索引或其他东西,因此它在 xcode 中看起来很好,但在文件系统上它是空的。

请参阅下面我的评论了解原因(xcode 4 的 mapc(地图编译器)已损坏)。

** 此问题已在较新的 Xcode/SDK 中修复。**

Turns out the Mapping Model needs to be part of the .xcdatamodeld package, which is impossible to do within xcode 4. With it in there, it works great.

Note: my mapping file stopped working again, and I found that it was 0KB on disc, so I had to recreate it again and it worked fine after that. I quickly committed it and will see if it disappears again. The problem is that Xcode 4 indexes it or something so it looks fine in xcode but on the file system its empty.

See my comment below for the reason (xcode 4's mapc (map compiler) is broken).

** THIS HAS BEEN FIXED IN THE NEWER XCODEs/SDKs.**

楠木可依 2024-10-31 17:02:41

我遇到了类似的问题:

我的 xcmappingmodel 中的自定义策略将不会 在我的例子中,它没有执行

,因为我的迁移没有对表进行任何更改 - 也许这也是您的问题。

I had a similar problem:

Custom Policy in my xcmappingmodel will not be executed

in my case it was not executed since my migration did not do any changes to the tables - maybe this is your problem too.

原谅我要高飞 2024-10-31 17:02:41

确保将源数据模型设置为旧版本,将目标设置为新版本...当这些模型向后时,我收到了上述错误。

Make sure to set up the source data model as your OLD version, and the destination as the new one... I have gotten the error above when these were backwards.

青瓷清茶倾城歌 2024-10-31 17:02:41

您需要创建架构的新版本,而不是更改当前版本。假设您已经这样做了,模型发生了什么变化?有些变化太过剧烈,无法可靠地推断。

you need to create a new version of the schema, as opposed to changing the current version. presuming you have done this, what changes have been made to the model? some changes are too drastic to be inferred reliably.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文