Re: Source list tree nodes able to represent different entities
Re: Source list tree nodes able to represent different entities
- Subject: Re: Source list tree nodes able to represent different entities
- From: Sebastian Morsch <email@hidden>
- Date: Mon, 31 Dec 2007 07:10:15 +0100
Thank you for the quick answer mmalc!
You're right, a "TreeNode" entity is probably not useful for concrete
objects that only represent other data entities. I will rather try
using it as an abstract superclass for my data entities to let them
inherit the attributes NSTreeController expects.
NSTreeController will then be assigned to the "TreeNode" entity rather
than its subclasses (the data entities) for the sake of flexibility.
I only will have to insert new objects directly into the managed
object context myself and not with NSTreeController's newObject method
because it would only create TreeNode-objects.
I hope I got it right now, thanks again!
Am 31.12.2007 um 02:34 schrieb mmalc crawford:
On Dec 30, 2007, at 4:51 PM, Sebastian Morsch wrote:
But I don't know how to work around the fact that a relationship
like my TreeNodes "representedObject" wants a single entity it
relates to. I want it to relate to more than one entity!
First, do you need to use a TreeNotes entity? Can you not just use
the data entities directly.
Note:
"An NSTreeController requires that you describe how the tree of
objects is traversed by specifying the key path for child objects.
All child objects for the tree must be key-value-coding compliant
for the same child key path. If necessary you should implement
accessor methods in your model classes, or categories on those
classes, that map the child key to the appropriate class-specific
method name."
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTreeController_Class/Reference/Reference.html
>
Unfortunately, the usual example-suspects (CoreRecipies, SourceList
Sample) seem to work with only one entity/class.
So does anyone know how to implement a source list tree that points
to objects of different entities? Any help is greatly appreciated!!
Thanks.
Use entity inheritance. Define an entity (perhaps abstract) that
defines the relationship, then implement the other entities as sub-
entities.
mmalc
_______________________________________________
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