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.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcbgjeh
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
使用c++17更新时出现G++编译器警告
it1352 06-18 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
复制文件夹/文件而不修改属性?
it1352 07-15