Observing NSArrayController's content, shouldn't it be simple ?
Observing NSArrayController's content, shouldn't it be simple ?
- Subject: Observing NSArrayController's content, shouldn't it be simple ?
- From: Yann Bizeul <email@hidden>
- Date: Mon, 7 May 2007 10:06:19 +0200
Hello list.
Again, fighting with KVO and CoreData.
Say an NSArrayController A in my nib, which contentSet is bound to
another NSArrayController B controller key:"selection", key path
"myRelation"
What I want to do is quite simple, I just want to register as an
observer for A's content, and get added/removed values.
So I do register like this :
[A addObserver:self forKeyPath:@"content" options:
NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
And I'm listening like this :
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context
{
NSLog(@"%@",change);
}
But all I get each time I add an object is :
{kind = 1; new = <null>; old = <null>; }
I also tried :
[A addObserver:self forKeyPath:@"arrangedObjects" options:
NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
Without more success...
The ONLY thing that seem to work is binding to the parent
NSArrayController :
[[B selection] addObserver:self
forKeyPath:@"myRelation.arrangedObjects" options:
NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
This is ok, but NOT :
[B addObserver:self
forKeyPath:@"selection.myRelation.arrangedObjects" options:
NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
Well, If someone understand my problem I would be glad to grab a hand
on this !
Thank you
Yann Bizeul - yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop - GeekTool - SSH Tunnel Manager - ...
http://projects.tynsoe.org/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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