Re: Rerun value transformer
Re: Rerun value transformer
- Subject: Re: Rerun value transformer
- From: Trygve Inda <email@hidden>
- Date: Wed, 20 Sep 2006 15:00:27 +0000
- Thread-topic: Rerun value transformer
> On Sep 20, 2006, at 2:19 AM, Trygve Inda wrote:
>
>> I have a value transformer that is ultimately controlling the
>> enabled state
>> of a button. The transformer needs some info that is only available
>> once the
>> app is fully running.
>>
>> [NSValueTransformer setValueTransformer:
>> [[[IsExportableValueTransformer
>> alloc] initWithObject:self] autorelease] forName: @"isExportable"];
>>
>> My value transformer class has an init method and gets a pointer
>> back to my
>> main AppController object so it can inquire about the data it needs.
>
> That sounds like the wrong approach. A value transform should
> transform a value of Kind A into a value of Kind B (and in the
> reverse direction if it supports it.)
>
> 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.
>
> 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.
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