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
(NSDocument
subclass) is created.MyDocument
creates a Core DataNSManagedObjectContext
that represents the document's data.MyDocument
instantiates anNSWindowController
from the storyboard by its identifier.Within the storyboard, the window controller contains
DocumentEditorViewController
(NSViewController
subclass) which displays and edits the document.Within the storyboard,
DocumentEditorViewController
has anNSArrayController
that's bound toMyDocument
's managed object context.Within the storyboard,
DocumentEditorViewController
has 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.