Re: Dependent values that are not iVars
Re: Dependent values that are not iVars
- Subject: Re: Dependent values that are not iVars
- From: Kyle Sluder <email@hidden>
- Date: Fri, 18 Dec 2009 11:28:44 -0800
On Fri, Dec 18, 2009 at 11:18 AM, Paul Bruneau
<email@hidden> 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.
--Kyle Sluder
_______________________________________________
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