MagicalRecord在静态库中:如何加载数据模型?

编程入门 行业动态 更新时间:2024-10-27 16:33:40
本文介绍了MagicalRecord在静态库中:如何加载数据模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在静态库中使用MagicalRecord与数据模型。 当我调用

I'm trying to use MagicalRecord with a data model in a static library. When I just call

[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"db.sqlite"];

在库中,似乎没有加载数据模型。调用

in the library, it doesn't seem to load the data model. A call to

[TheObject MR_createEntity];

会抛出异常:

could not locate an entity named 'TheObject' in this model.'

如何加载我想要使用的模型? 项目布局概述:

How do I load the model I want to use? An overview of the project layout:

我试图默认从主包中加载模型?

I figure MR tries to load the model from the main bundle by default?

[MagicalRecord setDefaultModelNamed:@"TheModel.xcdatamodeld"];

也不会找到它。 如果我尝试将库的模型资源文件复制到主项目,Xcode会崩溃。

will also not find it. And if I try to copy the library's model resource file into the main project, Xcode complains by crashing.

推荐答案

构建静态库为数据模型生成了一个编译的.mom文件。 (打开lib的Products组,右键单击编译的lib,在Finder中显示)此文件可以添加到主项目的资源,使其在主包中可用。

building the static library produced a compiled .mom file for the data model. (open the lib's Products group, right click the compiled lib, show in Finder) this file can be added to the main project's resources, making it available in the main bundle.

更多推荐

MagicalRecord在静态库中:如何加载数据模型?

本文发布于:2023-11-04 05:52:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   库中   加载   数据模型   MagicalRecord

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!