Re: Changes in KVO behavior on SL?
Re: Changes in KVO behavior on SL?
- Subject: Re: Changes in KVO behavior on SL?
- From: Kevin Brock <email@hidden>
- Date: Wed, 2 Sep 2009 05:47:07 -0700
On Sep 1, 2009, at 6:11 PM, Ken Thomases wrote:
On Sep 1, 2009, at 7:14 PM, Kevin Brock wrote:
We've got an app that is using keyValueForPath: and
observeValueForKeyPath:ofObject:change:context: to keep a status
window up-to-date.
On 10.5 it works fine. On 10.6 keyValueForPath: is called exactly
once per property. When we later create a change dictionary and
send observeValueForKeyPath:ofObject:change:context: to the
observer for a property, valueForKeyPath: isn't called again.
Huh? You have never been supposed to call -
observeValueForKeyPath:ofObject:change:context: yourself, nor
construct change dictionaries. When a property changes in a way
that KVO can't automatically track, you are supposed to call -will/
didChangeValueForKey: (or the corresponding will/didChange...
methods for set or array mutation) and KVO will generate the change
notification itself.
Good to know. I'll give that a try. Lot of legacy code in that part
of the app--I doubt that this is the last thing I'll run into.
Likewise, there's never been any guarantee that invoking -
observeValueForKeyPath:ofObject:change:context: will provoke the
receiver to call -valueForKeyPath: on the object whose property has
changed. If the observer wants, it can rely totally on the
information in the change dictionary. If you were using will/
didChange..., then KVO can be expected to invoke valueForKey: on the
object whose property is changing, but that's not what (you say)
you're doing.
Thanks. That was helpful. On 10.5 the receiver *does* apparently
always call valueForKeyPath, at least with the receivers we're talking
to. Maybe they weren't checking the dictionary on 10.5, or were
calling the fn if the data on the new values wasn't found in the
dictionary, but are being stricter on 10.6.
Kevin
_______________________________________________
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