On Dec 18, 2009, at 2:28 PM, Kyle Sluder wrote:

On Fri, Dec 18, 2009 at 11:18 AM, Paul Bruneau
<paul_brun...@special-lite.com> wrote:
          if ([keyPath isEqualToString:kOverallWidth]) {
                       [self willChangeValueForKey:@"overallWidth"];
NSLog(@"got notification that overallwidth changed:
%@", object);
                      [self didChangeValueForKey:@"overallWidth"];
         }

Please note that it is not correct to call -will/didChangeValueForKey:
without actually changing the value. The KVO mechanism might just
simply not send a notification at all. (Well, I guess it's valid, but
you might see fewer observation notifications than you would expect.)
This is difficult to get right with derived properties.

Also don't have the first inclination I had, which is to use
-keyPathsForValuesAffectingValueForKey:. As described in the
documentation, it will not work.

Ugh, so I guess you are saying that derived properties are not trustworthy in this usage?

I like them so much because then I never have to worry about the stored value being out of date (which admittedly, if I do everything exactly right, I guess it will never be out of date, but I like not having to worry about it).

It's also a bummer because so far it is working fabulously with willChange/didChange.

I might live dangerously and leave it in until it bites me.

Thanks for the warning, I'll make note of it.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to