Skip navigation.
 
mlRe: Simple Cocoa bindings question
FROM : Daniel Jalkut
DATE : Fri Apr 22 20:59:32 2005

I haven't done the currency converter tutorial, but I looked at the 
web page just now and I think I have a good idea of what's going on:

The "converted" text field is bound to the "amountInOtherCurrency" 
property of the model, which is, in the tutorial, a *read only* 
property.  It's derived from the dollarsToConvert property.

I think your bindings are already in place the way you want them - 
all you need to change is to make the "converted" text field's bound 
property "read/write".  I think if you implement a 
method :setAmountInOtherCurrency:" in the model, then everything 
should work exactly as you expect:

1. When you enter a value into the "amount in other currency" 
bindings will call the setAmountInOtherCurrency: method.
2. Your set method for this value should do a reverse conversion to 
dollars and call setDollarsToConvert: with the new value (or 
setValue:forKey:).
3. Setting the dollars to convert value will cause the bound dollars 
to convert text box to pick up the new (reverse converted) value to 
be picked up.

Daniel

On Apr 22, 2005, at 11:12 AM, M. Carlson wrote:

> The "Currency Converter" tutorial using Cocoa bindings is fine, as 
> far as it goes. I thought I would extend the program to be able to 
> convert both ways: not just from dollars to "other", but also from 
> "other" back to dollars (depending on which field the user 
> changes), akin to the way the Java web sites do it.
>
> Here's the problem: Because the "Amount in Other Currency" text 
> field is already bound to the Model Key Path of 
> "amountInOtherCurrency", it doesn't look possible to also bind it 
> to a new method, named "otherToConvert", to cause the dollar amount 
> to be recalculated?
>
> Is there a way to do this?
>
> -- M
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>-
> sweater.com
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlSimple Cocoa bindings question M. Carlson Apr 22, 20:12
mlRe: Simple Cocoa bindings question Daniel Jalkut Apr 22, 20:59