Theocacao
Leopard
Design Element
Comment on "Core Data: Forcing Propogation of Changes"
by Scott Stevenson — Jul 19
@Malcolm Hall: You should not be adding to or updating the binding context you should be adding to the controller the context is bound to

First, just to be clear, the phrase "binding context" can mean a lot of different things. At first, I thought you meant the data buffer that's passed in as the "context" argument in a -bind: method, but I'm pretty sure you mean the Managed Object Context that a controller is bound to.

In terms of adding objects, you absolutely can deal directly with the Managed Object Context, and I think this is arugably the preferred way. The NSArrayController is bound to the context, so you're just skipping the middle man. You might have a custom NSArrayController and want to use some logic from that, but that code can be anywhere.

There's nothing necessarily wrong with adding objects in code by talking to the NSArrayController, but it can be a lot slower in some cases (probably not in your example, though), and some of the methods don't take effect until the end of the current user event.

In my opinion, NSArrayController and NSTreeController should mainly be used when you need to connect user interface items to something.
Back to "Core Data: Forcing Propogation of Changes"
Design Element

Copyright © Scott Stevenson 2004-2015