Re: Boggled By Bindings
Re: Boggled By Bindings
- Subject: Re: Boggled By Bindings
- From: Patrick Machielse <email@hidden>
- Date: Fri, 01 Oct 2004 11:24:55 +0200
op 01-10-2004 00:55 schreef Jacob Lukas
>
On Sep 30, 2004, at 1:32 PM, Patrick Machielse wrote:
>
>
> I want to bind to a new ivar of my NSArrayController subclass, but somehow
>
> the change notifications never get send.
>
>
I had the same problem recently. What I found that works is using:
>
[self addObserver:self forKeyPath:@"arrangedObjects" options:nil
>
context:nil];
>
>
in awakeFromNib
[]
>
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
>
change:(NSDictionary *)change context:(void *)context
>
{
>
if (keyPath == @"arrangedObjects")
>
[self didChangeValueForKey:@"ivar"];
>
[super observeValueForKeyPath:keyPath ofObject:object change:change
>
context:context];
>
}
I don't like the fact of only sending 'didChange' here. Not sending
'willChange' will probalbly break 'undo' etc. However, I have found in the
past that using
[self willChangeValueForKey:@"ivar"];
[self didChangeValueForKey:@"ivar"];
Will reliably crash my applications :-(
>
I also had to override automaticallyNotifiesObserversForKey: exactly
>
how you did.
OK, so it's not _just_ me :-)
This solution does work, but I still think there must be a better way. A
_right_ way...
Patrick
---
Hieper Software
w: www.hieper.nl
e: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden