Cocoa Bindings: observeValueForKeyPath
Cocoa Bindings: observeValueForKeyPath
- Subject: Cocoa Bindings: observeValueForKeyPath
- From: Gabriele de Simone <email@hidden>
- Date: Fri, 23 Jan 2004 16:13:57 -0500
On my way to a full appreciation for Cocoa Bindings' power, I ran into
a problem. One of my objects registers to become an observer for the
arrangedObjects key in an NSArrayController:
[_itemsController addObserver:self
forKeyPath:@"arrangedObjects"
options:NSKeyValueObservingOptionNew |
NSKeyValueObservingOptionOld
context:nil];
My observeValueForKeyPath method looks like this. While this method is
called appropriately, every attempt to extract either the new or old
values for the given key result in a null object:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary*)change
context:(void *)context {
if (object == _itemsController) {
if ([keyPath isEqualToString:@"arrangedObjects"]) {
if ([[change objectForKey:NSKeyValueChangeKindKey]
intValue] == NSKeyValueChangeSetting) {
id oldValue = [change
objectForKey:NSKeyValueChangeOldKey];
id newValue = [change objectForKey:NSKeyValueChangeNewKey];
// both are nil!!!
}
}
}
}
This is a problem I am having in more than one class, always with the
same outcome.
Am I doing anything wrong?
Thanks
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.