{"id":242,"date":"2006-09-17T08:39:07","date_gmt":"2006-09-17T12:39:07","guid":{"rendered":"http:\/\/auroralux.net\/blog\/2006\/09\/17\/problems-with-cocoa-core-data-core-recipes-example\/"},"modified":"2006-09-27T07:23:19","modified_gmt":"2006-09-27T11:23:19","slug":"problems-with-cocoa-core-data-core-recipes-example","status":"publish","type":"post","link":"https:\/\/fhmiv.net\/blog\/2006\/09\/17\/problems-with-cocoa-core-data-core-recipes-example\/","title":{"rendered":"Problems with Cocoa Core Data &#8216;Core Recipes&#8217; Example"},"content":{"rendered":"<p>I&#8217;m working on a couple of applications using Cocoa and Core Data. I&#8217;m familiar enough with the KVO, KVC, and things like NSArrayController to write the app without Core Data, but it&#8217;s such a cool tool and I figured the data modeling tool and the data store would save me some time. <\/p>\n<p>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 <a href=\"http:\/\/developer.apple.com\/samplecode\/CoreRecipes\/index.html\">Core Recipes<\/a>, 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&#8217;d put it in the right places. <\/p>\n<p>I quit the app and fired it up again. This time, the app loaded, but I couldn&#8217;t get focus to  the app window or bring it to the front (&#8220;make key and order front&#8221;) 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&#8217;t get focus to it, and couldn&#8217;t even use the menu bar. I had to force it to quit using the Stop button in XCode. <\/p>\n<p>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. <\/p>\n<p>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. <\/p>\n<p>When I pause the app in the debugger, the stack trace goes like this: <\/p>\n<blockquote><p>\n#0        0x9000b268 in mach_msg_trap<br \/>\n#1        0x9000b1bc in mach_msg<br \/>\n#2        0x907dbb78 in __CFRunLoopRun<br \/>\n#3        0x907db47c in CFRunLoopRunSpecific<br \/>\n#4        0x931eb740 in RunCurrentEventLoopInMode<br \/>\n#5        0x931eadd4 in ReceiveNextEventCommon<br \/>\n#6        0x931eac40 in BlockUntilNextEventMatchingListInMode<br \/>\n#7        0x936eeae4 in _DPSNextEvent<br \/>\n#8        0x936ee7a8 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]<br \/>\n#9        0x936eacec in -[NSApplication run]<br \/>\n#10        0x937db87c in NSApplicationMain<br \/>\n#11        0x0000efa8 in main at main.m:13\n<\/p><\/blockquote>\n<p>I can&#8217;t imagine I&#8217;m the only one having this problem. Any ideas? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a couple of applications using Cocoa and Core Data. I&#8217;m familiar enough with the KVO, KVC, and things like NSArrayController to write the app without Core Data, but it&#8217;s such a cool tool and I figured the &hellip; <a href=\"https:\/\/fhmiv.net\/blog\/2006\/09\/17\/problems-with-cocoa-core-data-core-recipes-example\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[11],"_links":{"self":[{"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/posts\/242"}],"collection":[{"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/comments?post=242"}],"version-history":[{"count":0,"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/posts\/242\/revisions"}],"wp:attachment":[{"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/media?parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/categories?post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fhmiv.net\/blog\/wp-json\/wp\/v2\/tags?post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}