Re: NSTreeController, NSOutlineView + Core Data
Re: NSTreeController, NSOutlineView + Core Data
- Subject: Re: NSTreeController, NSOutlineView + Core Data
- From: Paul Forgey <email@hidden>
- Date: Wed, 5 Apr 2006 23:29:04 -0700
I'm in a similar situation but I'm not using Core Data. I'm
interested in following this thread to hopefully gets some insight
for my application too.
I put the smarts in my window controller rather than trying to
subclass either the tree controller or outline view. Also remember
that just because you are using Core Data and bindings doesn't mean
you can't still make use of the outline view's delegate methods.
As for the tree controller, I only have one column that's the
displayName for the entity and another part of the window for showing
details appropriate for whatever objects are selected. If you have
columns that don't apply to all the objects, uncheck "Raises For Non
Applicable Keys" in the binding and the field will be happily nil and
(I think) uneditable.
Since the tree controller manages objects of multiple data types, I
don't have it automatically preparing contents. Instead I respond to
the add: message in my window controller and insert my own instance
of the object into the appropriate position for the selection.
Since I have these different types which may contain or create
various other types, I made my node objects factories for their
children. So to add a child object to a non-leaf node, I ask the
parent node to create it. An option for a tree controller to do this
in addition to simply creating an object of a given class type would
be really nice.
Some of this of course is going to work differently in Core Data.
One huge advantage you have is nodes being smart enough all on their
own how to delete themselves.
On Apr 5, 2006, at 8:20 PM, Alex Reynolds wrote:
I have multiple entities in a Core Data model from which I would
like to build a hierarchy in NSOutlineView.
From the root leaves, I have one set of data from one entity; two
levels down, separate entities representing data of the type
represented by each parent node, e.g.:
Type A
|---------> Data of Type A
|---------> Data of Type A
|
Type B
|---------> Data of Type B
| |
| |----------> Data of Subtype of B
|---------> Data of Type B
| |
| |----------> Data of Subtype of B
|
etc.
Since I can't hook up a single binding (i.e. one entity) to the
NSOutlineView -- or I don't know how to build the above structure
from a single binding -- I've subclassed NSTreeController and
NSOutlineView so that I can try to build this kind of custom
structure into an array which I feed into the NSTreeController,
which I hope should in turn be displayed by NSOutlineView.
So I have a couple questions:
1. Is this a bad way to approach handling multiple Core Data
entities with an NSOutlineView object? Is there an easier way?
2. Are there any code samples that provide a simple demonstration
of how NSOutlineView and NSTreeController work together?
Thanks for any tips,
Regards,
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden