what's my binding?
what's my binding?
- Subject: what's my binding?
- From: matt neuburg <email@hidden>
- Date: Sat, 13 Mar 2004 09:37:46 -0800
How do I, a control in the interface, find out programmatically at runtime
what my bindings are?
Here's what I'm really trying to do. I have a lot of NSTextFields. These are
each bound in the nib to an NSObjectController (instantiated in the nib),
which in turn has a content outlet to an object (instantiated in the nib)
that has a lot of ivars. Each NSTextField's value corresponds to the value
of one of those ivars.
So far so good. When the user types in an NSTextField, the corresponding
ivar's value changes. When an ivar's value is changed with setValue:forKey:,
the displayed value in the corresponding NSTextField changes.
However, I have also implemented drag-and-drop for a couple of these
NSTextFields - I can drop a file on an NSTextField and it will display the
pathname of that file. I do this in the NSTextField class's
performDragOperation, by calling [self setStringValue:].
The problem is that calling [self setStringValue:] does *not* update the
corresponding ivar. Therefore I'm thinking to myself that the right way to
do this is for the NSTextField to say instead: "Well, what's my binding?" If
the NSTextField could learn this, it could find out what ivar it is
ultimately tied to, and could call setValue:forKey: to set that ivar
correctly, thus updating *both* the ivar *and* its own displayed string
value.
Is this the right approach, and if so, how do I do it? I can't find any
methods that would lead me from the one thing I know (namely "self") to the
NSObjectController, its content outlet, and the ivar to which self is
ultimately tied. Or maybe there's a whole different way to do this and I'm
just not seeing what it is...? Thx - m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.