Re: NSValueTransformer - Object Reference
Re: NSValueTransformer - Object Reference
- Subject: Re: NSValueTransformer - Object Reference
- From: "b.bum" <email@hidden>
- Date: Sat, 17 Jul 2004 10:36:25 -0700
On Jul 17, 2004, at 12:10 AM, Jonathan Younger wrote:
Is there anyway to get a reference to the object that the value
transformer is bound to when the "- (id)transformedValue:(id)aValue"
and "- (id)reverseTransformedValue:(id)aValue;" methods are called?
There is not. One possible workaround is to use the
NSValueTransformer binding option to specify a specific instance of
your NSValueTransformer that has a reference back to the controller.
You'll need to do this programatically (see my previous post for an
example).
However, with that said....
Generally, value transformers are intended to be stateless converters
between type (a) and type (b). If you need state beyond, say,
application level configuration information, then it is likely that
there is an alternative architecture that is potentially simpler and
certainly more in line with the intentions of value transformers.
I'm trying to emulate something similar to a NSTableColumn using the
arrangedObjects from an NSArrayController. I have an array of custom
views where each view corresponds to a record in the array controller
and I want the controls in the custom view to be bound like what can
be done with binding a NSTableColumn.
For example with a NSTableView I could bind column 1 to
arrangedObjects.someProperty and column 2 to
arrangedObjects.someOtherProperty in an NSArrayController.
When the table view displays each record in the NSArrayController the
NSTableColumns display the proper values for each record.
Each of the table columns contains a separate binding upon its own key
path to the objects contained within the arrangedobjects. So, no magic
there.
I'd like to do something similar and bind an NSTextField to
arrangedObjects.someProperty and a different NSTextField to
arrangedObjects.someOtherProperty in my custom view. When my custom
views are displayed each view would display the proper record from the
NSArrayController that the controls are bound to.
Why not bind the text fields to arrangedObjects.whateverProperty
directly as you describe? That should "just work" (unless I'm
misunderstanding the intent).
The alternative would be bind arrangedObjects directly to your custom
view, then provide additional bindings on the custom view that specify
which key should be used for each of the display components (or just
hardwire until you need that level of flexibility).
b.bum
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.