• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa Bindings: observeValueForKeyPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Cocoa Bindings: observeValueForKeyPath
      • From: Gerard Iglesias <email@hidden>
  • Prev by Date: Re: XCode annoyance :-\
  • Next by Date: Re: NSTask Memory Problems
  • Previous by thread: Re: XCode annoyance :-\
  • Next by thread: Re: Cocoa Bindings: observeValueForKeyPath
  • Index(es):
    • Date
    • Thread