Re: Manual Cocoa Binding - Custom Value Transformer
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.