Re: checkbox question
Re: checkbox question
- Subject: Re: checkbox question
- From: Quincey Morris <email@hidden>
- Date: Sat, 22 Aug 2009 19:08:25 -0700
On Aug 22, 2009, at 18:11, Michael de Haan wrote:
OK...that certainly clarifies one thing....so, one **cannot** bind
to an object, but to that object's properties? (Hence the error when
I tried that).
The error occurred because you bound a binding that requires a numeric
value to something that produced a non-numeric value.
If in IB you bind to an object and leave the "model key path" (i.e.
the property) blank, it defaults to "self", which is a property of
NSObject that returns the object itself. So you can bind to an object,
by implicitly or explicitly using its "self" property.
Perhaps I am not using the checkbox correctly, but I wish the label
to illustrate that checked represents one type of unit ( eg pounds)
and unchecked another ( eg kilograms).
I'd suggest you label the checkbox something like "Use metric system
for weights". In addition, you might want to go the trouble of adding
a text label that says "lb" or "kg" after each measurement shown in
your window.
If you did that, you could add a "measurementUnits" property to your
window controller:
+ (NSSet*) keyPathsForValuesAffectingMeasurementUnits
{
return [NSSet setWithObject: @"state"];
}
- (NSString*) measurementUnits
{
return state ? @"kg" : "lb";
}
and then bind each of the text labels to that property. Then when you
click the checkbox, all the text labels will change automatically.
_______________________________________________
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