External datasource for Core Data

Discussion in 'Mac Programming' started by awnispel, Dec 25, 2010.

  1. awnispel macrumors newbie

    Aug 2, 2010
    San Jose, CA USA
    I apologize up front for the detailed description that follows. Binding core data to an array controller seems complicated and full of pitfalls. Perhaps some Cocoa wiz can sound this out and tell what I did wrong. I was following MacTech's tutorials on Core Bindings by Jeff LaMarche, and wished to make a slight modification where I assign data to a core data object from an external RSS feed so as to fill a tableview of book titles, rather than provide data from user input. To my dismay, all the tutorials I've come by use user input instead of an external data source for some reason.

    Here's what I did: I have a NSArrayController 'Books' that I bound to a Core Data entity 'Book', with a 'title' attribute. Now in the NSArrayController's Inspector, the mode is set to 'Entity' and the name is set to 'Book'--which I believe is the correct procedure. In order to populate the tableview, I bind it's column to my array controller of 'Book' entities that I named 'Books'. Also, in the inspector's bindings tab, I have set the 'Managed Object's' binding to my database file, 'MTCoreDataAppDelegate', and the model key path to 'manageObjectContext'.

    In my core data delegate class I have typed in an outlet for 'books' which I then attached (or bind) to the array controller 'Books' within the Interface Builder. Yet when I compile and run the application, the code line: '[books setValue:thisStringContent forKey:mad:"title"], of the implementation file causes the log error message: "[<NSArrayController 0x31ac00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key title."

    I should add that I believe everything is connected up correctly since I am able to add default data (from a textfield for user input) to my tableview by using the following statement: '[books add:nil]'. Therefore, it seems I have somehow miss-labeled my key name, 'title' with respect to the entity 'book' attribute, 'title', but how can this be?

    Screen shots of my inspector settings are in my public folder in 'help' folder at:

    Thanks for any help you might suggest.
  2. vocaro macrumors regular

    Mar 5, 2004
    If NSArrayController is giving you trouble, consider not using it at all. It's only a convenience class anyway. I did lots of Core Data coding on iOS without ever using it.
  3. BadWolf13 macrumors 6502

    Dec 17, 2009
    I'm curious about this myself. Has anyone done core data on OSX without an array controller?

Share This Page