core data key/value observation failure
core data key/value observation failure
- Subject: core data key/value observation failure
- From: "John R. Timmer" <email@hidden>
- Date: Thu, 02 Nov 2006 13:44:44 -0500
I'd assumed I was hallucinating, but this bug has now bitten me in
two separate projects. During an "awakeFromNib" method, i have the
following code, which loops through a series of managed objects:
aPref = [prefArray objectAtIndex: loopCounter];
[aPref addObserver: self forKeyPath: @"showInTable" options:
NSKeyValueObservingOptionNew context: NULL];
NSLog ( [aPref valueForKey: @"theDisplayName"] );
The callback for changes just looks like this:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
anObject change:(NSDictionary *)change context:(void *)context {
NSLog ( @"got a change notification" );
return;
The output of the run log is as follows:
2006-11-02 13:34:31.090 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.090 Mouse Manager[16164] Unique ID
2006-11-02 13:34:31.090 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.091 Mouse Manager[16164] Cage Name
2006-11-02 13:34:31.091 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.091 Mouse Manager[16164] Cage Location
2006-11-02 13:34:31.092 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.092 Mouse Manager[16164] Active
2006-11-02 13:34:31.092 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.092 Mouse Manager[16164] # of Mice
2006-11-02 13:34:31.093 Mouse Manager[16164] got a change notification
2006-11-02 13:34:31.093 Mouse Manager[16164] Mice
Which is all as it should be - one notification per object
(presumably as they wake from fetch?). While using the app, however,
changing one of these objects never triggers the notification (in
this case, it's the object with "Active"). I cannot for the life of
me figure out why, but i've seen the exact same behavior in a
separate project.
I've searched the archives, but didn't come across this; if someone
could help me out before I go insane, i'd appreciate it.
Cheers,
John
____________________________________
Science writer, Ars Technica (among other things)
http://arstechnica.com/journals/science.ars
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden