(no subject)
(no subject)
- Subject: (no subject)
- From: Sam Stigler <email@hidden>
- Date: Thu, 24 May 2007 02:28:18 +1000
I was going to write out an answer saying it would be very simple,
etc. using a set of reverse value transformers and NSString, but then
I realized that you can't access ivars from value transformers.
Having realized that, your best option might be, hard as it to say,
simply not to use bindings in this case. The other option is to see
if you can find a way to subclass whatever you're inserting things
into (I assume an NSArrayController) to allow for custom behavior
(such as appending text etc.) when something is inserted. If you can
find a way to do this, you could write a value transformer for
firstName that adds a "_f_" (for example) before it, and another one
for lastName that adds a "_l_" before it -- all you'd really need is
some hint to know how to manipulate the fullName string. Or, if you
don't want to take the risk that your user won't put in that prefix,
you could make your transformedValueClass be a dictionary with two
values: The original string as passed in, and whether it is a
firstName or a lastName. You could then handle those in your custom
insert (or add?) method.
I'm sorry, I haven't looked at the documentation for
NSArrayController recently. I hope this helps.
-Sam
http://www.stigler.org/sam/wordpress
On May 24, 2007, at 1:44 AM, Jerry Krinock wrote:
Say that I have an NSTableView with two columns, firstName and
lastName. Say that some marketing hack insists that I store these
combined as one string.
For the last hour, I've been trying to figure out how to bind two
table columns such as this to a single string in storage,
bidirectionally, using Cocoa bindings. But I keep running into a
wall, trying to transform two objects into one. What's the smart way
to do this?
Thanks,
Jerry Krinock
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden