Re: Binding tablecolumn to attribute of specific object in to-many relationship?
Re: Binding tablecolumn to attribute of specific object in to-many relationship?
- Subject: Re: Binding tablecolumn to attribute of specific object in to-many relationship?
- From: Dado Colussi <email@hidden>
- Date: Wed, 30 Mar 2011 18:27:10 -0500
On 30 March 2011 17:02, Sean McBride <email@hidden> wrote:
> On Tue, 29 Mar 2011 18:15:28 -0700, Quincey Morris said:
>
> >On Mar 29, 2011, at 14:57, Sean McBride wrote:
> >
> >> I've considered adding a optional transient to-one relationship to
> >> Department named 'employeeId0' and binding the tablecolumn to
> >> departmentsArrayController>arrangedObjects>employeeId0>name, but maybe
> >> I'm barking up the wrong tree....
> >
> >There's no obvious reason from your description why employee ID 0 needs
> >to be a Core Data property. Surely it can just be a normal derived
> property.
> >
> >Also, if it has no particular significance other than for populating the
> >list, there's no real reason to implement the property in the data model
> >itself. It seems more natural to implement it in your window controller.
> >
> >But I don't see anything actually wrong with your original suggestion,
> >if you have a compelling reason to go that way.
>
> Quincey,
>
> Thanks for your reply. However, I'm not sure I understand you exactly.
> By 'normal derived property' do you mean in this sense:
>
> <http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/
> CoreData/Articles/cdFAQ.html#//apple_ref/doc/uid/TP40001802-SW3<http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#//apple_ref/doc/uid/TP40001802-SW3>
> >
>
> That FAQ is actually pretty darn close to my original question really.
> But it's a little vague. I've never been clear on when/where it's safe
> to use KVO from one managedobject to another. It says "You must add and
> remove the parent [Department] as an observer as child objects
> [Employees] are added to and removed from the relationship". Where's
> the correct place to catch items being added to/removed from a
> relationship? By implementing addEmployeesObject: and
> removeEmployeesObject: in my Department class?
>
I have a similar situation where one of my to-many entities has a special
role. I added an extra non-transient to-one relationship (non-transient
because I can't infer the special role from the attributes).
I think Quincey is saying that, in your custom entity class, you could
implement a normal (read-only) property that gets the special entity from
the to-many relationship. Your problem would reduce to handling KVO.
In my case, I worked around the KVO issue by making the child assign itself
as the special child: self.reverseRelationship.specialChild = self. My
parent and child are extremely tightly coupled anyway, so I considered this
OK.
/Dado
_______________________________________________
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