0

I am trying to set up the binding between Core Data, NSArraycountroller and a NSTableView. To get a NSManagedObjectContext for the NSArrayController. I dragged an NSObject in the IB, and named it after the appDelegate and then set up the binding of objectContext between appDelegate and the arrayController.

However, whenever I tried to run the app. I get this error message:

The error message:

The managed object model version used to open the persistent store is incompatible with
the one that was used to create the persistent store

And then followed by another error message:

Failed to initialize store.

I googled around, most of the people can solve this issue by clean their project or delete the files under ~/Library/Application Support/AppName/.. But I don't have luck with those.

Another thing is that, I desperately want some good tutorial on this topic (CoreData+ArrayController+TableView). Can someone shed some light on this as well? I read through the chapter 11 of the book "Cocoa Programming for Mac OSX 4th version", but didn't find it really helpful.

Thanks.

4

2 回答 2

1

终于解决了这个问题。我认为这与 Reskit 有关。与 CoreData 捆绑时,Reskit 有自己的 managedObjectContext。这就是为什么它一直告诉我两个对象模型不兼容的原因。NSArrayController 应该绑定到 RKManager 中的 managedObjectContext 而不是 appDelegate 中的那个。

所以我把它放在视图控制器的init方法中:

RKObjectManager *objectManager = [RKObjectManager sharedManager];
currentObjectContext = objectManager.objectStore.managedObjectContextForCurrentThread;

并将NSArrayController对象中的managedObjectContext指向currentObjectContext。

于 2012-06-13T13:55:13.750 回答
0

该错误与您的托管对象模型有关;它与您的绑定或表格视图无关。如果它发生在您运行应用程序时(与您尝试打开文档时相比),则可能是在恢复自动保存的文档期间。

尝试从~/Library/Autosave Information中删除任何相关内容,看看是否能解决最初的问题。

于 2012-06-12T19:59:49.483 回答