Re: Displaying multiple core data relationships in NSOutlineView
Re: Displaying multiple core data relationships in NSOutlineView
- Subject: Re: Displaying multiple core data relationships in NSOutlineView
- From: Volker in Lists <email@hidden>
- Date: Fri, 16 Jan 2009 15:57:24 +0100
Hi,
why don't you have an abstract class that holds the children/parent
relationships and make different subclasses for different data types
that all inherit from your abstract class. As far as I understand your
problem, that should solve it. I have a similar solution working well
for me.
Cheers, Volker
Am 16.01.2009 um 15:38 schrieb Rick Hoge:
I'm still trying to get my head around how to achieve a particular
outline view display by binding an NSTreeController to Core Data
entities.
I have some test apps running in which, by binding my tree
controller to a "root" entity, I can get a nice outline view showing
a hierarchy of child entities as long as these descend from the root
via a series of to-many relationship with a fixed relationship name
(i.e. "children"). Add, remove, and addChild all work as expected.
Now comes the messy part. Is there any way to add a hierarchical
view of a second hierarchy of to-many relationships descending from
the *same* root object in the *same* outline view? (i.e.
"children2" ) It would be easy in a second outline view, but I'd
like to have both hierarchies shown in a single outline view - one
above the other.
The design I'm trying to achieve is analogous to the way Xcode
displays a "Targets" group and a "Bookmarks" group in the same
outline view. If Core Data was used for this (and I don't know if
it was), it seems clear that Targets and Bookmarks would be modeled
as separate to-many relationships and entities, and yet they are
nicely displayed in the same outline view.
I'm guessing that this might be achievable by using the same name
"children" for the to-many relationships in both hierarchies, and
adding a custom "children" accessor method to the root object that
returns the appropriate set of entities to show in the outline
view. It's not clear to me how this would be set up though.
I tried something like the code shown below in a custom "Project"
class, for the project entity:
-(NSMutableSet*)children {
return [NSMutableSet setWithObjects:
[self mutableSetValueForKey:@"targets"],
[self mutableSetValueForKey:@"bookmarks"],
nil];
}
but I get the error message
2009-01-16 09:35:02.047 004 ProjectProto[83363:10b]
[<_NSNotifyingWrapperMutableSet 0x1057dd0>
addObserver:forKeyPath:options:context:] is not supported. Key path:
children
I have the feeling I'm missing something at a really basic level -
if anyone can suggest how to achieve the above design I'd be very
grateful.
Cheers,
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