Re: Simple Cocoa bindings question
Re: Simple Cocoa bindings question
- Subject: Re: Simple Cocoa bindings question
- From: Daniel Jalkut <email@hidden>
- Date: Fri, 22 Apr 2005 11:59:32 -0700
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@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
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