Re: Rerun value transformer
Re: Rerun value transformer
- Subject: Re: Rerun value transformer
- From: Trygve Inda <email@hidden>
- Date: Thu, 21 Sep 2006 05:15:24 +0000
- Thread-topic: Rerun value transformer
> On Sep 20, 2006, at 11:00 AM, Trygve Inda wrote:
>
>>> Since you ultimately want to control the button's enabled state, you
>>> only need a value transformer if your model object doesn't have a KVO
>>> compliant key for its exportable state that returns a boolean.
>>
>> I do not have a key that returns a BOOL as.
>
> What logic does your value transformer use to return a BOOL then?
>
>>> Value transformers can't get "re run". They aren't push/pull. The are
>>> on-demand coercers of data.
>>>
>>> You button should be bound, through a controller, to the isExportable
>>> key of your model. That key should be KVO compliant. You likely
>>> shouldn't be (or don't need to) use a value transformer at all.
>>
>> The problem is that at launch time, some data is not yet loaded
>> when the
>> value transformer is called. I need the value transformer to be hit
>> again...
>> I thought that asking the button to redraw itself would invoke the
>> binding
>> tied to the value transformer.
>
> That is not how it works. The buttons isEnabled is bound (preferably
> through a controller) to a model object with a KVO compliant key.
> When that key changes, the new enabled state will be reflected in the
> UI.
>
> Forget about the value transformer for the time being and so you can
> take a step back and figure out what it is you want to do.
>
> It sounds like you want the button to be enabled when your model is
> in an exportable state, right?
>
> What key path have you bound the buttons enabled to?
I have an array controller that manages the contents of an NSTable. The
array is an array of dicts. The button enabled state is in two parts - the
first being the canRemove state of the ArrayController. No problem there...
When an item is selected, the button is highlighted.
The second aspect is harder... I need to run a method isExportable which
takes a dict (from the active row). If true, then the button should be
enabled.
Currently I am trying to run it as a valueTransformer so that it is
automatically called whenever the array selection changes. But isExportable
can't work until the app is fully up and running. So what happens is that
when the app launches, the button is not enabled as it shuld be but then
works fine as the selection is changed in the table.
So now I am using a isExportable transformer on selectedObjects of the
array.
Trygve
_______________________________________________
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