Re: Custom Bindings clarification
Re: Custom Bindings clarification
- Subject: Re: Custom Bindings clarification
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 27 Jan 2004 09:18:08 -0800
On Jan 27, 2004, at 8:36 AM, mmalcolm crawford wrote:
If you just want to establish a binding, you can do it programatically:
[textField bind: @"backgroundColor" toObject: $sourceObject
withKeyPath: $backgroundTextColorKey options:nil];
In the case of a colour binding, "of course", you'll also have to
specify at least one binding option -- to use NSUnarchiveFromData
(since you can't store colours directly in Preferences).
You might therefore end up with code that looks something like this:
NSMutableDictionary *bindingOptions = [NSMutableDictionary
dictionary];
[bindingOptions setObject:NSUnarchiveFromDataTransformerName
forKey:@"NSValueTransformerName"];
// other options
[textField bind: @"backgroundColor"
toObject: [NSUserDefaultsController sharedUserDefaultsController]
withKeyPath:@"values.backgroundTextColor"
options:bindingOptions];
I've put a complete example at:
<
http://homepage.mac.com/mmalc/CocoaExamples/
ManualBindingsColourPreference.zip>
mmalc
_______________________________________________
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.