Re: Self KVO...
Re: Self KVO...
- Subject: Re: Self KVO...
- From: Ken Thomases <email@hidden>
- Date: Thu, 09 Oct 2014 23:13:59 -0500
On Oct 9, 2014, at 10:56 PM, Randy Widell <email@hidden> wrote:
> I’m not sure I am having a hard time figuring this out and I am just not finding anything via Google. I am writing a NSTextFieldCell subclass and I want to recalculate the size whenever the string value changes via a binding. What I can’t seem to figure out is how to observe the change. I could register each instance with itself for change notifications, but that just seems like an odd way to go about it. Seems like it should be possible to just override setValue:forKeyPath:, but that never seems to be called.
I would expect that the control will call -setObjectValue: on the cell when it (the control) receives a new value via the binding.
It may not be the case that the control ever gets -setValue:forKey: when the property to which it is bound changes. That's one possible way for the implementation to work, but as least as likely is for the control to have -observeValueForKeyPath:… to be called on it because it was using KVO to observe the property to which it is bound.
In any case, the cell should be entirely insulated from the way in which the control received its new value. When implementing a cell, you should not need to care about bindings or whatever.
Regards,
Ken
_______________________________________________
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
References: | |
| >Self KVO... (From: Randy Widell <email@hidden>) |