Skip navigation.
 
mlCoreData and Bindings - a single, simple entity with bindings
FROM : Marcus Roberts
DATE : Sun May 01 10:59:49 2005

I've been trying out CoreData, reading through the excellent
cocoadev.com tutorials, and the documentation on Apple's developer
site.    All of the examples so far link an interface of tables
through NSArrayControllers back to the managed context.  These all
work fine.

What I'm trying to do is instantiate a single entity object in a
document.  Taking it back to basics, I defined an entity in the data
model, with two fields, name and email.  I then option-click and drag
the entity onto a new empty document window in Interface Builder, and
when asked, choose One Object instead of Many Objects.

When I run the application created, the document window appears, with
two empty fields, but the document data is marked as needing to be
saved, as the red window close button has the dark dot in the middle.
If I type into each text field, then press Apple-Z to undo, the two
fields clear in turn, and then they become disabled with "No
Selection" written in them.

I'm not quite sure what's happening here.  In an equivalent 10.3
program, I would have instantiated a model object, and using bindings
and an NSObjectController linked the view to the model.  The document
wouldn't need saving until the user typed values into the field.

Can anyone explain the behaviour - I'm guessing it's probably pretty
simple, and to do with the managed context's behaviour in creating an
entity object, but I'm not sure.  Or is it more complex, and due to
needing a graph of objects rather than just a single object?

Thanks

Marcus

Related mailsAuthorDate
mlCoreData and Bindings - a single, simple entity with bindings Marcus Roberts May 1, 10:59
mlRe: CoreData and Bindings - a single, simple entity with bindings Marcus Roberts May 1, 11:30
mlRe: CoreData and Bindings - a single, simple entity with bindings mmalcolm crawford May 2, 08:37
mlRe: CoreData and Bindings - a single, simple entity with bindings Tom Birch May 2, 08:40