• 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 using multiple keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding using multiple keys


  • Subject: Re: Binding using multiple keys
  • From: Ricky Sharp <email@hidden>
  • Date: Sat, 17 Sep 2005 10:41:16 -0500


On Sep 16, 2005, at 6:42 PM, Glen Simmons wrote:

I have a text field that I'd like to bind to a "duration" key. The problem is that the value returned by the duration method needs to be adjusted based on the value of a popup that has "Hours", "Days" and "Weeks". So if the duration comes back 48, but the popup is set to to "Days", I need to show "2" instead of "48". Any suggestions on how to accomplish this?

Use dependent keys. You already have an attribute of 'duration' that will be a normalized duration (i.e. the minimum resolution unit you need; looks like hours in your case).


Add another attribute 'durationUnit' (int) and bind your popup to that.

Add a third attribute 'displayableDuration' (int) and set it as dependent on both duration and durationUnit. Your displayableDuration getter will be responsible for returning the actual number that should be displayed. Note that you don't need to add a setDisplayableDuration method since changes to that computed value will come in only via changes to duration and durationUnit.

Finally, bind your text field's value to displayableDuration.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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


References: 
 >Binding using multiple keys (From: Glen Simmons <email@hidden>)

  • Prev by Date: Re: Rotating NSViews
  • Next by Date: setStandardInput Argument
  • Previous by thread: Binding using multiple keys
  • Next by thread: NSData returns YES on Fail?
  • Index(es):
    • Date
    • Thread