• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding a text field's editable binding to a matrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding a text field's editable binding to a matrix


  • Subject: Re: Binding a text field's editable binding to a matrix
  • From: Guy English <email@hidden>
  • Date: Wed, 19 Jan 2005 14:05:24 -0500

Mmalcs example does exactly what you need but lest you think your
writing a  class for this one circumstance is over kill you can make
your transformer much more generic.

With the this transformer you can test for any value. Registering
*instances*  instead of classes gives you lots of opportunity for this
kind of thing.

Anyway - Mmalcs code hacked a litte:

@interface NumberEqualityTestTransformer

+ (Class)transformedValueClass;
+ (BOOL)allowsReverseTransformation;

- (void) setTestValue: (id) aNumber;
- (id)transformedValue:(id)aNumber;

@end

@implementation NumberEqualityTestTransformer

+ (Class)transformedValueClass
{
     return [NSNumber class];
}

+ (BOOL)allowsReverseTransformation
{
     return NO;
}

- (void) setTestValue: (id) aNumber
{
    [aNumber retain];
    [testNumber release];
    testNumber = aNumber;
}

- (id)transformedValue:(id)aNumber
{
     if  ( [aNumber isEqualToNumber: testNumber]  {
         return [NSDecimalNumber one];
     }
     return [NSDecimalNumber zero];
}

@end

MyDocument or wherever is appropriate:

+ (void)initialize
{
     NumberEqualityTestTransformer *transformer =
[[[NumberEqualityTestTransformer alloc] init] autorelease];

     [transformer setTestValue: [NSNumber numberWithInt: 2]];

     [NSValueTransformer setValueTransformer:transformer
forName:@"TwoIsTrueTransformer"];

     NumberEqualityTestTransformer *transformer =
[[[NumberEqualityTestTransformer alloc] init] autorelease];

     [transformer setTestValue: [NSNumber numberWithInt: 3]];

     [NSValueTransformer setValueTransformer:transformer
forName:@"ThreeIsTrueTransformer"];
}
 _______________________________________________
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

  • Follow-Ups:
    • Re: Binding a text field's editable binding to a matrix
      • From: Keith Renz <email@hidden>
    • Re: Binding a text field's editable binding to a matrix
      • From: mmalcolm crawford <email@hidden>
References: 
 >Binding a text field's editable binding to a matrix (From: Keith Renz <email@hidden>)
 >Re: Binding a text field's editable binding to a matrix (From: mmalcolm crawford <email@hidden>)
 >Re: Binding a text field's editable binding to a matrix (From: Keith Renz <email@hidden>)
 >Re: Binding a text field's editable binding to a matrix (From: mmalcolm crawford <email@hidden>)
 >Re: Binding a text field's editable binding to a matrix (From: Keith Renz <email@hidden>)
 >Re: Binding a text field's editable binding to a matrix (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Defining Accessors in a Custom Palette for a NSArray for Cocoa Bindings
  • Next by Date: Re: Building a GUI for a command line tool.
  • Previous by thread: Re: Binding a text field's editable binding to a matrix
  • Next by thread: Re: Binding a text field's editable binding to a matrix
  • Index(es):
    • Date
    • Thread