• 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
Fine-grain control of KVO? How to get old and new values of observed objects' bound keys?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fine-grain control of KVO? How to get old and new values of observed objects' bound keys?


  • Subject: Fine-grain control of KVO? How to get old and new values of observed objects' bound keys?
  • From: Don Briggs <email@hidden>
  • Date: Thu, 26 Feb 2004 10:35:09 -0800

Hello, Cocoa Bindings gurus 

I am exploring a subclass of NSArrayController.
Presently, when instances of my subclass receive notification of a
change in the method

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context

the change: argument dictionary is always nil.
Instead, I would like this method access the old and new values for
some keyPaths.

I don't see how to do this in Interface Builder's bindings inspectors.
It seems wrong-headed (and, so far in my discovery, fruitless)
to try to override this behavior programmatically in the observed
objects.

For this case, I had hoped to select a column of the table in Interface
Builder and specify that, for its bound key path, the observed objects
would receive something like

NSKeyValueObservingOptions fineGrainOptions =
( NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld );

as the options argument in the method

- (void)addObserver:(NSObject *)observer
forKeyPath:(NSString *)keyPath
options:(NSKeyValueObservingOptions)options
context:(void *)context

when the forKeyPath: argument is the table column's key path.

Another approach is to implement a hacque in
- (void)willChangeValueForKey:(NSString *)key;
- (void)didChangeValueForKey:(NSString *)key;
in the observed objects, but that seems clunky because it would tie the
model to its controller layer.

All best,
Don
_______________________________________________
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.


  • Prev by Date: Re: Problems with Distributed Objects
  • Next by Date: CocoaInCarbon printing
  • Previous by thread: Re: NSProgressIndicator display when stopped?
  • Next by thread: CocoaInCarbon printing
  • Index(es):
    • Date
    • Thread