Core Data & UIManagedDocument in Xcode 4.3: Can't merge models

本秂侑毒 提交于 2020-01-24 12:05:48

问题


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...


回答1:


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



来源:https://stackoverflow.com/questions/10545613/core-data-uimanageddocument-in-xcode-4-3-cant-merge-models

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!