Re: Is willChangeValueForKey: always needed?
Re: Is willChangeValueForKey: always needed?
- Subject: Re: Is willChangeValueForKey: always needed?
- From: Scott Stevenson <email@hidden>
- Date: Thu, 16 Nov 2006 18:32:45 -0800
On Nov 16, 2006, at 4:22 PM, David Catmull wrote:
I have a case where the value in question is calculated based on
other values (which tab is selected, and whether a certain text
field has text), and the key is simply the name of the method that
calculates the value. So when one of those other values changes,
it's too late to say that the calculated value "will" change.
I believe the "willChange" method gives KVO a change to pick up the
current value. What is done with that depends on who's observing.
It don't think it will break anything if you leave it out, but you
generally shouldn't have to call this manually anyway. As long as
your methods are KVC compliant and you're not doing anything special,
it should all just work.
- The unit test calls [goButton isEnabled] and unexpectedly gets NO
- The unit test calls [controller canGo] and gets YES as expected
I thought perhaps willChangeValueForKey: might be caching the "old"
value to see if it really does change, but the canGo method doesn't
seem to get called there.
The user experience that this test is trying to simulate does in
fact work correctly - when you type something into the text field
and the correct tab is active, the button becomes enabled.
Perhaps the button's value doesn't actually get updated until the end
of the run loop? The user wouldn't see a difference but the test would.
- Scott
_______________________________________________
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