• 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
Re: Cocoa Bindings: observeValueForKeyPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Bindings: observeValueForKeyPath


  • Subject: Re: Cocoa Bindings: observeValueForKeyPath
  • From: Gerard Iglesias <email@hidden>
  • Date: Fri, 23 Jan 2004 23:10:14 +0100

Hi,

I am not using binding that way, I use directly the 'object' parameter, but did you make

NSLog(@"%@", change);

To see what is in it ?, I am curious of that ...

Regards

Gerard

Le Jan 23, 2004, ` 10:13 PM, Gabriele de Simone a icrit :

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.
_______________________________________________
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.

References: 
 >Cocoa Bindings: observeValueForKeyPath (From: Gabriele de Simone <email@hidden>)

  • Prev by Date: Re: NSTask Memory Problems
  • Next by Date: How to get mouse moved events?
  • Previous by thread: Cocoa Bindings: observeValueForKeyPath
  • Next by thread: How to get mouse moved events?
  • Index(es):
    • Date
    • Thread