Re: Core Data/IB questions
Re: Core Data/IB questions
- Subject: Re: Core Data/IB questions
- From: "Adam Gerson" <email@hidden>
- Date: Thu, 27 Mar 2008 12:11:06 -0400
Is what you are describing similar to the "To Dos" example at:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
Adam
On Thu, Mar 27, 2008 at 5:33 AM, Ian Jackson <email@hidden> wrote:
> If I may be so bold, I'd like to jump in on this question. I have a
> similar situation, but I want to have a table representing a to-many
> relationship for entity1, which the user can populate by choosing any
> number of entries from a entity2.
>
> e.g. entity2 has 50 entries.
>
> entity1 1st entry refers to entries 1, 4, and 9 of entity 2.
> entity1 2nd entry refers to entries 4, 8 and 26 of entity 2.
>
> So I envisage that the table in entity1 should have add and remove
> buttons. When you click add, a new row is added to the table. The
> first column in the table is a NSCombobox, which can be used to select
> from the entries in entity 2.
>
> The employee/department tutorial seems to come close to doing this,
> but as seems to be more the norm, it assumes that all entries in the
> relationship are wanted, which is not the case here.
>
> So, I set up the interface as above (table with NSCombobox, and +/-
> buttons). I created a special array controller just for this to-many
> relationship, and bound its contentset to the relevant relationship in
> entity1.
> The first column in the table is bound to the specially created array
> controller, arrangedObjects, but this is a dead end. I can't see how
> to make the combobox choose the entry. The combo box doesn't have the
> same binding options as a popup menu.
>
> Any advice as to how to approach this would be great.
>
> Ian.
>
>
>
>
> On 27/03/2008, at 7:34 PM, Adam Gerson wrote:
>
> > I think that internally when you create a to-many core-data
> > relationship the group of objects is stored as an NSSet as opposed to
> > an array.
> >
> >
> > http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html
> >
> > http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#/
> > /apple_ref/doc/uid/TP40002147-181724
> >
> > http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/
> > /apple_ref/doc/uid/20002174-178830-BAJEDEFB
> >
> >
> > On Thu, Mar 27, 2008 at 2:10 AM, Rick Mann <email@hidden>
> > wrote:
> >>
> >> On Mar 26, 2008, at 11:06 PM, Adam Gerson wrote:
> >>> Each table should have its own ArrayController if the two tables
> >>> represent the data from two different entities. Since you entities
> >>> are
> >>> related I am assuming one entity has a property that is a to-many
> >>> relationship to the other entity. Set the ContentSet bindings for
> >>> ArrayController2 to be the selection of ArrayController1.
> >>>
> >>> ArrayController2 ContentSet
> >>> Bind to = ArrayController1
> >>> Controller Key = selection
> >>> Model Key Path = (the name of the relationship that represents
> >>> entity2
> >>> in entity1)
> >>>
> >>> This will cause ArrayController2 to always populate the TableView
> >>> with
> >>> the objects selected by ArrayController1
> >>>
> >>> Let me know if that needs to be more clear.
> >>
> >>
> >> Excellent! That was exactly what was missing. Thank you.
> >>
> >> Why ContentSet, and not ContentArray or one of the other ContentXXX
> >> things?
> >>
> >> --
> >> Rick
> >>
> >>
>
> > _______________________________________________
> >
> > Cocoa-dev mailing list (email@hidden)
> >
> > Please 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
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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