Problems with Cocoa Core Data ‘Core Recipes’ Example

I’m working on a couple of applications using Cocoa and Core Data. I’m familiar enough with the KVO, KVC, and things like NSArrayController to write the app without Core Data, but it’s such a cool tool and I figured the data modeling tool and the data store would save me some time.

For some reason, examples of Core Data applications seem pretty rare on Google, and whenever I try to search for them I have to filter out a lot of crap about Weight Watchers. Apple does have one decent example application called Core Recipes, a recipe application built on Core Data. I downloaded that, opened it up in XCode, let it upgrade the project file, built, and ran it. No recipes showed up in the app and I knew it came with some sample data and included a spotlight importer for slightly more sample data, so I read the meager documentation included with the demo to make sure I’d put it in the right places.

I quit the app and fired it up again. This time, the app loaded, but I couldn’t get focus to the app window or bring it to the front (“make key and order front”) using the mouse. When I moved all the other windows out of the way so CoreRecipes was the only thing left, I found I still couldn’t get focus to it, and couldn’t even use the menu bar. I had to force it to quit using the Stop button in XCode.

I think it has something to do with the data store files. It uses the Core Data XML data store by default. It expects its main library to be in ~/Library/Application Support/CoreRecipes/CoreRecipesLibrary.crx, and is supposed to use the Spotlight Importer to find other available recipe files.

Whenever there is a CoreRecipesLibrary.crx in the Library directory, the app exhibits this frozen behavior on launch. If I delete that file, it launches fine. If I then add chefs, ingredients, and recipes of my own, save and then quit, a CoreRecipesLibrary.crx is created in the standard location, and the next time I launch it, the app exhibits the freezing behavior.

When I pause the app in the debugger, the stack trace goes like this:

#0 0x9000b268 in mach_msg_trap
#1 0x9000b1bc in mach_msg
#2 0x907dbb78 in __CFRunLoopRun
#3 0x907db47c in CFRunLoopRunSpecific
#4 0x931eb740 in RunCurrentEventLoopInMode
#5 0x931eadd4 in ReceiveNextEventCommon
#6 0x931eac40 in BlockUntilNextEventMatchingListInMode
#7 0x936eeae4 in _DPSNextEvent
#8 0x936ee7a8 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#9 0x936eacec in -[NSApplication run]
#10 0x937db87c in NSApplicationMain
#11 0x0000efa8 in main at main.m:13

I can’t imagine I’m the only one having this problem. Any ideas?

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

3 Responses to Problems with Cocoa Core Data ‘Core Recipes’ Example

  1. frank says:

    The mystery deepens — I was having these problems this weekend with Core Recipes on my dual 500 G4 at home, running 10.4.7 and XCode 2.4.

    At work on my dual g5 with 10.4.7 and XCode 2.4, it runs fine. I’m not certain whether it’s the same version of the Core Recipes code or data, because I downloaded them at different times. I’ll have to check that out.

  2. frank says:

    I never did figure out exactly what was wrong with this one. It’s working both at home and at work now, though the Spotlight importer is spotty.

    The best thing I got out of this was a set of troubleshooting steps for Cocoa/XCode applications that seem very thorough; hopefully the subject of another post.

  3. Pingback: the blogging » Closing the loop on Core Recipes

Comments are closed.