• 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: Custom Bindings clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Custom Bindings clarification (From: Peer Allan <email@hidden>)
 >Re: Custom Bindings clarification (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: How to get non-resolved FSRef from POSIX path
  • Next by Date: Re: Any new/updated Cocoa books soon?
  • Previous by thread: Re: Custom Bindings clarification
  • Next by thread: Making a String from a non-NSString
  • Index(es):
    • Date
    • Thread