0
votes

I am trying to write a very simple Core Data OS X application.

Here's what I've done so far:

  1. Create a new Core Data application called PortalMan. This also created an NSAppDelegate called PortalManAppDelegate.
  2. Go to the PortalMan.xcdatamodeld data model and create a new entity called Repo with three attributes: active, branch, path. active is a Boolean, the other two are Strings.
  3. Open the interface editor for MainMenu.xib
  4. Drag a new NSArrayController to the document space
  5. On the Attributes tab of the NSArrayController, set the "Mode" to "Entity Name" and set the "Entity Name" attribute as "Repo"
  6. Check the "Prepares Content" box
  7. On the Bindings tab for the NSArrayController, select the Managed Object Context binding. Enable it, and bind it to the "Portal Man App Delegate".
  8. Set "Model Key Path" to "managedObjectContext".
  9. Drag a table view to the window
  10. Add a column, and in its "Value" Binding, set "Bind To: Array Controller", set the "Controller Key" to "arrangedObjects" and the "Model Key Path" to "branch"

I also added a button and bound it to the Array Controller's add method.

When I try and run my application, I get this error:

2012-01-06 16:01:43.650 PortalMan[656:707] An uncaught exception was raised
2012-01-06 16:01:43.651 PortalMan[656:707] [<NSApplication 0x100401750> valueForUndefinedKey:]: this class is not key value coding-compliant for the key branch.

This makes me think it's not grabbing my Core Data "Repo" model appropriately, because "Repo" does have a "branch" attribute.

Any thoughts on this or how I can debug it?

Thanks!

1
Read the error message again: Repo may have a branch attribute, but the application object does not. You tried to get the branch of the application object, not a Repo, and that's why it failed.Peter Hosey

1 Answers

0
votes

I accidentally selected a "Content Array" binding at some point.

I removed that binding and everything works perfectly as I'd expect now.

Thanks! Hope this helps someone else. If you're having issues like this: REVIEW ALL THE BINDINGS ON YOUR NSArrayController!