Re: custom control's value change isn't being noticed by controller
Re: custom control's value change isn't being noticed by controller
- Subject: Re: custom control's value change isn't being noticed by controller
- From: Quincey Morris <email@hidden>
- Date: Thu, 26 Feb 2009 17:15:42 -0800
On Feb 26, 2009, at 13:21, Steve Christensen wrote:
I've written a custom control containing multiple NSTextFieldCells.
The combined cell values result in a single integer value accessed
via the control's intValue/setIntValue: and objectValue/
setObjectValue: (as a NSNumber).
The control is correctly displaying the current value when it's
bound to a controller's someValue method, but if I edit one of the
cells in the control, the controller's setSomeValue: isn't firing to
pick up the change. When editing finishes, my control's
textDidEndEditing: method is called. I calculate the updated control
value and call [self setObjectValue:[NSNumber
numberWithInteger:value]] to get observers to notice the change but
nothing happens.
There's some possible terminological trouble in here.
What do you mean by "bound"? If you've given your control a genuine
binding (and it won't work unless you implement all of the correct
binding behavior), then it's up to your implementation to propagate
view-initiated changes. Or are you using "bound" loosely to refer to
some non-binding form of KVO relationship?
What do you mean by "firing"? 'setSomeValue:' is a setter method --
it's invoked, it doesn't fire. Maybe you mean the related KVO
notification. That's triggered when (and because) you invoke the
setter. It doesn't happen for any other reason.
What do you mean by "observers"? Or, rather, what objects do you think
are observing the 'objectValue' property of your control? The only way
an "observer" would notice that you call 'setObjectValue:' is if it
registered for notifications of the 'objectValue' property, and I'm
pretty sure that the controller hasn't done that.
If you really want your control to be bindable, it has to have the
behavior described in here:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html#/
/apple_ref/doc/uid/20002373
If you want something else, a good first step would be to get bindings
out of the discussion.
HTH
_______________________________________________
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