RE: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?
RE: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?
- Subject: RE: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?
- From: "Jon C. Munson II" <email@hidden>
- Date: Tue, 24 Feb 2009 10:48:46 -0500
- Organization: JTA Enterprises LLC
>
> > 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
>
[Jon C. Munson II] With regards to the dox, and I'm not being grumpy or
"short" when saying this, if, situationally speaking, these things were
*explicitly* explained (and not just "conceptually" explained), I'd probably
have a better time of it. I'm NOT one of those people who learn well from
reading technical documentation, particularly if that documentation is
geared more to conceptions than real-world/practical example. This is why
Hillegass' book was extremely useful to me as I could see the concepts put
into practice. I tend to learn best by doing and asking questions. Not
that I don't read the technical dox - I do in order to attempt to arrive at
the answers myself before "bothering" anyone. Sometimes I can get answers
out of the dox, when the answers I need are finite to the topic discussed.
However, when they start to cross boundaries (as is this case), then I have
a harder time putting two and two together. Bottom line is, I don't
necessarily learn easily/readily by reading technical documentation (good
examples are my best friend, me being a more visual/kinesthetic type). And
yes, that's a pain in my tail that I can't always get the
references/inferences within the documentation. Guess I'm just not as smart
as some of those on this list in that manner.
That being said, I did think there was some sort of message that
NSArrayController was responding to. I had hoped there was a method or
delegate method one could employ that would get implemented in response to
whatever message that is, but didn't see one.
Not knowing which/what message to search for prompted the post.
Having said that, and following with what you replied, I found this on the
'net (typos not withstanding):
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(managedObjectContextUpdatedNotification:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:[self managedObjectContext]];
Assuming that goes in init, is this the correct message, etc., to be
listening for?
I am curious about something though. Since the array controller providing
data for the table view is my custom subclass of NSArrayController, and it
is obviously responding to that message (provided the above is the correct
message), why is it that there's no method one can override in the
NSArrayController class to implement custom functionality based on the
receipt of the message? It seems that registering two listeners (if,
indeed, one is registered for the base NSArrayController class) is a little
redundant.
Anyway, I do appreciate the time and patience of those on the list who do
take the time to reply and offer assistance.
Thanks for the help!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden