Re: NSArrayController and variable number of NSTextFields
Re: NSArrayController and variable number of NSTextFields
- Subject: Re: NSArrayController and variable number of NSTextFields
- From: Kevin <email@hidden>
- Date: Sat, 3 Feb 2007 11:57:10 -0600
The fields I was talking about have labels, and are actually
NSTextViews that grow/shrink in height as needed. The labels need to
be displayed along with the NSTextViews. NSTableView wouldn't be able
to do this sort of thing. If I simply needed to display text values
of all the attributes, sure, I would just use an NSTableView. So,
this isn't your typical master-detail bindings setup with two
NSTableViews.
And just for clarification, fields don't just come and go. They are
in fact defined by users themselves.
Kevin
On Feb 3, 2007, at 11:39 AM, Matt wrote:
On Sat, 3 Feb 2007 08:29:16 -0600, Kevin <email@hidden>
said:
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 NSTextFields (one NSTextField per
attribute) housed in a custom NSView. Since an Item can have any
number of Attributes, I need to create a variable number of
NSTextFields 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
NSTextFields can be bound to indices in an NSArrayController. i.e. If
an Item has 3 attributes, I need to bind textfield1 to index0,
textfield2 to index1 and textfield3 to index2. In essence, it'd be
similar to how NSTableColumn works with NSArrayController.
Why not actually *use* an NSTableColumn (in an NSTableView)? That
is the
usual interface for displaying a variable number of values. Users
will like
this better than fields that come and go. And it will work with no
further
work on your part; you will have a classic master-detail bindings
architecture, on which there is a great deal of documentation
already. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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