Re: Rerun value transformer
Re: Rerun value transformer
- Subject: Re: Rerun value transformer
- From: Jim Correia <email@hidden>
- Date: Wed, 20 Sep 2006 08:53:42 -0400
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.
The problem is that after it is all loaded, I need to "fire" the
transformer
again so properly set the button state... Since the transformer
needs data
that is only obtained after applicationWillFinishLaunching completes.
Calling [myButton setNeedsDisplay:YES] does not work.
Any thoughts?
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.
Jim
_______________________________________________
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