I'm building an OS X app that uses core data, NSDocument, storyboards, and Cocoa bindings.
My expectation is that the following occurs:
An instance of
MyDocument(NSDocumentsubclass) is created.MyDocumentcreates a Core DataNSManagedObjectContextthat represents the document's data.MyDocumentinstantiates anNSWindowControllerfrom the storyboard by its identifier.Within the storyboard, the window controller contains
DocumentEditorViewController(NSViewControllersubclass) which displays and edits the document.Within the storyboard,
DocumentEditorViewControllerhas anNSArrayControllerthat's bound toMyDocument's managed object context.Within the storyboard,
DocumentEditorViewControllerhas a table view that's bound to theNSArrayController.
This way any changes in the UI make it all the way to the NSManagedObjectContext, without any glue code.
I expect this to be straightforward, as I believe I'm using these technologies in the way they are intended. However I have been unable to get the bindings to work, particularly at steps 5 and 6. All of the project templates and example projects I've found either don't use Core Data, don't use storyboards, or don't use NSDocuments.
Which objects should be bound to which? What should teh NSArrayController's class, keys and keypath be?
Another way to answer this question is to point out a working sample project that uses all these technologies together.