Take the 2-minute tour ×

I created a small test Mac app using the Core Data template (on Lion 10.7 and Xcode 4). I used the example on this site, http://www.swampfoetus.net/chapter-7-fail/, to hook up all the Cocoa Bindings with a tableview, an NSArrayController, a text box and an Add button. The NSArrayController is linked to the managedObjectContext of the App Delegate.

Everything seems to work fine when I launch the app ... I can type in text and press Add, and it gets saved in the tableview. I saved a few rows, and then pressed Save in the file menu (linked to the saveAction IBAction) and quit the app. I can see the data being saved in the xml data file (I renamed it .xml ... the PSC is of type NSXMLStoreType).

The problem is that when I launch the app again, it launches without the data that was saved in the Core Data file in the previous run.

This happens each time ... I can add data and it keeps appending to the data file, but at launch it never seems to read from this data file.

Any ideas what could be wrong here? I haven't messed around with the App Delegate generated code at all, only set up the bindings which seem to work fine. What could I check to make sure it's setup correctly?

share|improve this question
add comment

1 Answer

If the data shows up in the persistent store, then the only explanation would be a problem with the binding where the UI doesn't display the previous data for some reason. It's hard to say why that is happening but my guess would be a fetch predicate or some other bound qualifier that causes the controller to ignore older objects so that they are not displayed.

I can't say for sure because I don't have access to the book.

This is one of the drawbacks of using bindings. When they work, they're fantastic but when they don't, they're a @#%! to debug.

share|improve this answer
Ya, it's really confusing ... not sure if it might have something to do with Lion and AutoSave, though the template doesn't seem to suggest it, and I tried on a 10.6 machine as well, and same issue. –  Z S Sep 19 '11 at 21:46
add comment

Your Answer


