Re: Binding a text field's editable binding to a matrix
Re: Binding a text field's editable binding to a matrix
- Subject: Re: Binding a text field's editable binding to a matrix
- From: mmalcolm crawford <email@hidden>
- Date: Wed, 19 Jan 2005 10:23:31 -0800
On Jan 19, 2005, at 10:14 AM, Keith Renz wrote:
Implement a value transformer that takes in a number value and
outputs a number -- 1 if the input is '2', 0 otherwise.
That's a good idea. I'll give it a try. In reality, this requires more
code than using target/action and outlets. So maybe this is one of
those cases where bindings is overkill. Regardless, it's a good
learning example for me.
It shouldn't be too much extra work, and I suspect still less than the
glue code (if only barely)...
mmalc
@implementation TwoIsTrueTransformer
+ (Class)transformedValueClass
{
return [NSNumber class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (id)transformedValue:(id)aNumber
{
int intValue = [aNumber intValue];
if (intValue == 2) {
return [NSDecimalNumber one];
}
return [NSDecimalNumber zero];
}
@end
MyDocument or wherever is appropriate:
+ (void)initialize
{
NSValueTransformer *transformer = [[TwoIsTrueTransformer alloc]
init];
[NSValueTransformer setValueTransformer:transformer
forName:@"TwoIsTrueTransformer"];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden