On Tue, Feb 24, 2009 at 9:16 AM, Jon C. Munson II <jmun...@his.com> wrote:
> The user adds records on one screen. On a different screen, there is an > NSArrayController to which an NSTableView is hooked. When the records are > added on the first screen, the tableview (on the other screen) updates > itself automagically (AFAIK I wrote no code to facilitate that behavior). I > have a custom view that is also on that other screen that will need to > update itself as well to match - it isn't based on that same array > controller however. You might easily dismiss mmalc's sentiment in your other thread as grumpiness if you weren't paying close attention, but in fact his observation (and assertion) is spot-on. With respect, you are asking *a lot* of questions about an advanced Cocoa technology that depends on other technologies you clearly haven't studied yet in any reasonable depth. This "automagic" operation you're asking about is handled by Cocoa Bindings (collective term for Key Value Coding and Key Value Observing with the supporting controller layer including NSArrayController). It is not the same thing as Core Data and in fact you can use either of these technologies without ever touching the other (Core Data still uses KVC/KVO but can be used without the supporting controller layer Bindings provides), but they are most easily used together unless you're a sadist. With this in mind, however, you MUST learn the ins and outs of Bindings (and ITS prerequisites) if you're going to use it with Core Data in any but the most basic of application architectures. In his response, mmalc quoted this (in the Before You Start section at the beginning of the Core Data Programming Guide): "Core Data is not an entry-level technology. It leverages many other Cocoa technologies, including memory management, key-value coding, and key-value observing. You must understand these technologies to use Core Data effectively." DO NOT IGNORE THIS. Read ALL the prerequisites and MAKE SURE YOU UNDERSTAND THEM so you are not wasting your own time, let alone asking the list to repeat the conceptual documentation when you should be reading it carefully for yourself. The list is a valuable place to come to ask for clarification when doing your homework, but it is not a substitute for homework ... > So, my question is, how is the array controller receiving notification of > the newly added records so that I can, hopefully, do the same with my custom > view? It's done by having the array controller observe (via KVO, using the Bindings mechanism) the managed object context. When it changes, the array controller updates itself (by performing a 'fetch'). The only thing about this that is specific to Core Data (ie, not part of the usual Bindings - and by extension, KVC/KVO) is the fact that the array controller is observing the MOC as opposed to some other keypath of some other KVC/KVO-compliant object. This is explained -- I.S. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com