核心数据Xcode 4.3中的UIManagedDocument:无法合并模型 [英] Core Data & UIManagedDocument in Xcode 4.3: Can't merge models
问题描述
我要感谢所有为这个网站做贡献的人。我是一个编程的noob的一个h * ll,你都帮助我这么多。
我正在创建一个使用 UIManagedDocument
的应用程序为我存储一个核心数据模型。我使用创建 UIManagedDocument
与以下代码,但现在与Xcode 4.3.2(更新与Mac App Store)我有一个问题。
这里是代码:
NSURL * url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
url = [url URLByAppendingPathComponent:@MyFile];
NSLog(@\\\
\\\
此行打印。\\\
\\\
);
UIManagedDocument * document = [[UIManagedDocument alloc] initWithFileURL:url];
NSLog(@\\\
\\\
此行不打印\\\
\\\
);
我在控制台中收到如下错误:
由于未捕获的异常NSInvalidArgumentException而终止应用程序,原因:无法将名为Foo的两个不同实体的模型合并
这里的东西,我不是想获得版本或类似的东西工作。我只是创建一个数据模型与两种类型的实体,并试图获取一个UIManagedDocument在我的应用程序打开:超级简单,对吗?
我已经卸载Xcode并重新安装它没有运气。我也删除了我的核心数据模型,并重新从头开始没有运气。
我完全失去了,已经花了约2晚试图解决这个问题。 p>
帮助我!请!谢谢阅读。如果你需要任何更多的信息让我知道。我会给你我的灵魂的答案...
所以我想出来了。
$ b
我很难相信我不得不继承UIManagedDocument。最终我没有必要。我有一些问题与我的文件的方式链接到项目。
我按照这里的步骤,这一切都很好
I'd like to thank all the people that contribute to this website. I am one h*ll of a noob at programming and you all help me out so much. With that said, let's get on with my latest problem!
I am creating an app that uses a UIManagedDocument
to store a Core Data model for me. I use to create the UIManagedDocument
with the following code, but now with Xcode 4.3.2 (The one that updates with the Mac App Store) I have an issue.
Here's the code:
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
url = [url URLByAppendingPathComponent:@"MyFile"];
NSLog(@"\n\n This line does print. \n\n");
UIManagedDocument *document = [[UIManagedDocument alloc] initWithFileURL:url];
NSLog(@"\n\n This line does not print \n\n");
I receive an error in the console that goes like this:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'Foo''
Here's the thing, I'm not trying to get versions or anything like that to work. I'm simply creating a data model with two types of entities, and trying to get a UIManagedDocument to open in my app: super simple, right?
I have uninstalled Xcode and reinstalled it to no luck. I have also deleted my Core Data Model and redone it from scratch with no luck.
I am completely lost and have already spent about 2 nights trying to troubleshoot this.
Help me! Please! Thanks for reading. If you need anymore information let me know. I'll give you my soul for an answer...
So I figured it out.
I had a hard time believing that I had to subclass UIManagedDocument. Ultimately I didn't' have to. I had some problems with the way my files were linked to the project.
I followed the steps here and it's all good now
core data application is Crashing in iphone device
这篇关于核心数据Xcode 4.3中的UIManagedDocument:无法合并模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!