Re: key path blues
Re: key path blues
- Subject: Re: key path blues
- From: Glen Simmons <email@hidden>
- Date: Thu, 1 Feb 2007 14:48:00 -0600
On Feb 1, 2007, at 1:10 PM, Stephen Deken wrote:
[[self polCurve] setDwell:3.9];
[self setValue:[NSNumber numberWithFloat:3.9]
forKeyPath:@"polCurve.dwell"];
These two methods do the exact same thing, so it's not surprising that
they're both failing in the same way. What does your -[setDwell:]
function look like? It should look something like this:
-(void) setDwell:(float)v
{
[self willChangeValueForKey:@"dwell"];
_dwell = v;
[self didChangeValueForKey:@"dwell"];
}
If you leave off the will/didChangeValueForKey parts, KVO doesn't know
the value has changed and won't update any bound objects.
This is incorrect. Calling -setFoo: will always trigger a binding
that is bound to the "foo" key. The will/didChange pair is only
required if you directly change the variable, or if you change
something else that the bound key relies on. They can also be used to
trigger the binding without calling the -setXXX: method.
Glen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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