• 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: Manual Cocoa Binding - Custom Value Transformer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manual Cocoa Binding - Custom Value Transformer


  • Subject: Re: Manual Cocoa Binding - Custom Value Transformer
  • From: "b.bum" <email@hidden>
  • Date: Sat, 17 Jul 2004 10:29:22 -0700

On Jul 16, 2004, at 11:09 PM, Jonathan Younger wrote:
> NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
> [bindingOptions setObject: transformer
> forKey:@"NSValueTransformerName"];
> [myControl bind:@"value" toObject:arrayController
> withKeyPath:@"selection.optionValue" options:bindingOptions];
>
> The error returned for either of these examples is: Cannot find value
> transformer with name MyCustomValueTransformer

There are two solutions:

(1) register your value transformer via...

+ (void)setValueTransformer:(NSValueTransformer *)transformer
forName:(NSString *)name;

... on NSValueTransformer....

[NSValueTransformer setValueTransformer: [[[MyCustomValueTransformer
alloc] init] autorelease] forName: @"MyCustomValueTransformer"];

... then pass the name for the NSValueTransformerName option...

NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject: @"MyCustomValueTransformer"
forKey:@"NSValueTransformerName"];
[myControl bind:@"value" toObject:arrayController
withKeyPath:@"selection.optionValue" options:bindingOptions];

(2) Bind with a specific instance of NSValueTransformer...

MyCustomValueTransformer *valueTransformer =
[[[MyCustomValueTransformer alloc] init] autorelease];
NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject: valueTransformer
forKey:@"NSValueTransformer"];
[myControl bind:@"value" toObject:arrayController
withKeyPath:@"selection.optionValue" options:bindingOptions];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Manual Cocoa Binding - Custom Value Transformer
      • From: Brent Gulanowski <email@hidden>
References: 
 >Manual Cocoa Binding - Custom Value Transformer (From: Jonathan Younger <email@hidden>)

  • Prev by Date: Re: NSHost class
  • Next by Date: Re: NSValueTransformer - Object Reference
  • Previous by thread: Re: Manual Cocoa Binding - Custom Value Transformer
  • Next by thread: Re: Manual Cocoa Binding - Custom Value Transformer
  • Index(es):
    • Date
    • Thread