Fine-grain control of KVO? How to get old and new values of observed objects' bound keys?
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.