Re: Binding to a specific element in an array
Re: Binding to a specific element in an array
- Subject: Re: Binding to a specific element in an array
- From: Kevin <email@hidden>
- Date: Sun, 4 Feb 2007 14:59:27 -0600
Thanks for the reply. I already have a custom view which is bound to
the selected "Item". I can also manually bind each text view to an
Attribute, but then I'm binding views "directly" to the model and
bypassing any controller.
I would like the text views to be bound to a controller which is
bound to the Attribute objects. Without a controller, I lose the
benefits of NSEditor and NSEditorRegistration which NSController and
its subclasses provide.
Kevin
On Feb 4, 2007, at 2:48 PM, I. Savant wrote:
Actually, I thought someone answered this thread -- but I'll take
a shot at it.
I think I'd approach this problem by creating my own custom view.
The view can be bound to your "Item" instance and dynamically add
text fields (binding them to each of the attributes) as attributes
are added or removed.
Check out the Graphics Bindings and Manual Bindings examples here:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
... for ideas on how to create a custom view using bindings.
--
I.S.
On Feb 4, 2007, at 3:30 PM, Kevin wrote:
I have a related question. I posted the following yesterday but
didn't get any answers:
I have a Core Data application which consists of two entities,
Item and Attribute. Item has to-many relationship with Attribute.
In the application, Items are displayed in an NSTableView bound to
an NSArrayController. I have a second NSArrayController which
holds the selected Item's attributes.
When the user clicks an Item in the table, I'd like to show each
of its Attributes using a set of NSTextViews (one NSTextView per
attribute) housed in a custom NSView. Since an Item can have any
number of Attributes, I need to create a variable number of
NSTextViews and dynamically bind them to the second
NSArrayController which holds the selected item's attributes.
The issue is that there doesn't appear to be a way where
individual NSTextViews can be bound to indices in an
NSArrayController. i.e. If an Item has 3 attributes, I need to
bind textview1 to index0, textview2 to index1 and textview3 to
index2. In essence, it'd be similar to how NSTableColumn works
with NSArrayController.
I know I can do this portion manually (without using bindings) but
I'd like to avoid writing code that manages the content of the
text views.
Is there any way this can be done using bindings?
Kevin
On Feb 4, 2007, at 1:35 PM, I. Savant wrote:
On Feb 4, 2007, at 2:13 PM, Stuart Rogers wrote:
Yes, and definitely far less time than the amount I've already
spent trying to do it all without glue code.
So it would seem. :-)
I'm a creature of habit, and I tend not to waver from the first
way I find to get a job done, so I wanted to be sure that there
wasn't a quicker method than by using glue code.
Well, as I said, there may be, but I don't think there is. The
approach I suggested will certainly work just fine.
--
I.S.
_______________________________________________
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:
40xheadsoftware.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