Re: NSArrayController's selectedIndexes
Re: NSArrayController's selectedIndexes
- Subject: Re: NSArrayController's selectedIndexes
- From: Negm-Awad Amin <email@hidden>
- Date: Mon, 11 Aug 2008 11:55:01 +0200
Am Sa,09.08.2008 um 09:32 schrieb Ryan Brown:
Never mind, the "(Missing) KVO notification old and new values"
section on mmalc's Cocoa Bindings Examples and Hints confirmed that
this is a bug. It mentions that this won't be fixed for the
forseeable future... could someone elaborate as to why?
Hi,
it is, because there is no reason to do it.
- You can retrieve the new value with -infoForBinding: + KVC.
NSDictionary* bindingInfo = [self infoForBinding:@"boundProperty"];
id newValue = [[bindingInfo objectForKey:NSObservedObjectKey]
valueForKeyPath:[bindingInfo objectForKey:NSObservedKeyPathKey]];
- you can retrieve the old value from your ivar. Remember: Binding
means, that a property of the bound object synchronizes with a
property of an observed object. So the value of your property at the
beginning of -observeValue:… is the old value:
id oldValue = [self boundProperty];
Amin
Ryan
On Aug 9, 2008, at 12:24 AM, Ryan Brown wrote:
When I observe an NSArrayController's selectedIndexes key like so:
- (void)awakeFromNib {
[arrayController addObserver:self forKeyPath:@"selectionIndexes"
options:(NSKeyValueObservingOptionNew |
NSKeyValueObservingOptionOld) context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
NSLog(@"change: %@", change);
}
I'm never seeing the old and new indexes. I always see output like:
2008-08-09 00:14:04.513 test[12498:10b] change: {
kind = 1;
new = <null>;
old = <null>;
}
[arrayController selectedIndexes] gives the correct new value. A
table view is bound to the array controller in a typical
configuration (selectedIndexes is bound to the array controller).
Any ideas?
Ryan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Amin Negm-Awad
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden