FROM : Chris Hanson
DATE : Mon Mar 24 03:08:43 2008
On Mar 23, 2008, at 4:55 PM, Adam Gerson wrote:
> A specific question:
It is always good to ask specific questions. "Is ____ still broken in
10.5?" is not a very specific question, especially since there may be
a number of developers who are using it quite successfully in Mac OS X
10.4.
> If I want to model parent and child entities that have a
> completely different set of attributes (one is a group of objects, the
> other is the objects themselves) am I better of not using
> NSTreeController and CoreData?
NSTreeController and Core Data are entirely orthogonal here --
specifically, Core Data has nothing at all to do with your question.
Your question would be the same regardless of whether Core Data is
involved.
> One problem I have already run into is
> that when you bind your entire OutlineView column to a
> NSTreeController entity it wants the parents and children to all have
> the same attributes.
NSTreeController expects every column of an NSOutlineView it is
controlling to have the same attributes, and it expects every object
at every level of the hierarchy it displays to use the same keys for
both the children of a node and for whether a node is a leaf. That's
just how NSTreeController is designed.
One way you can interoperate with this in your own code is to *not*
bind directly to modeled attributes and relationships, but instead
bind to keys that you define in categories in your own code. For
example, let's say you're showing a filesystem hierarchy. You have
two classes of item, File and Folder, where File instances are leaf
nodes and Folder instances can have contents. You could add -
isLeafForTreeController and -childrenForTreeController methods to each
class, to return the appropriate values.
You may also be able to work with NSTreeNode objects directly -- which
are used to represent the contents of an NSTreeController in 10.5 --
but unfortunately how to do so is still very sparsely documented.
(It's not clear to me whether you can just set the content of a tree
controller to a collection of NSTreeNode instances, for example.)
-- Chris
DATE : Mon Mar 24 03:08:43 2008
On Mar 23, 2008, at 4:55 PM, Adam Gerson wrote:
> A specific question:
It is always good to ask specific questions. "Is ____ still broken in
10.5?" is not a very specific question, especially since there may be
a number of developers who are using it quite successfully in Mac OS X
10.4.
> If I want to model parent and child entities that have a
> completely different set of attributes (one is a group of objects, the
> other is the objects themselves) am I better of not using
> NSTreeController and CoreData?
NSTreeController and Core Data are entirely orthogonal here --
specifically, Core Data has nothing at all to do with your question.
Your question would be the same regardless of whether Core Data is
involved.
> One problem I have already run into is
> that when you bind your entire OutlineView column to a
> NSTreeController entity it wants the parents and children to all have
> the same attributes.
NSTreeController expects every column of an NSOutlineView it is
controlling to have the same attributes, and it expects every object
at every level of the hierarchy it displays to use the same keys for
both the children of a node and for whether a node is a leaf. That's
just how NSTreeController is designed.
One way you can interoperate with this in your own code is to *not*
bind directly to modeled attributes and relationships, but instead
bind to keys that you define in categories in your own code. For
example, let's say you're showing a filesystem hierarchy. You have
two classes of item, File and Folder, where File instances are leaf
nodes and Folder instances can have contents. You could add -
isLeafForTreeController and -childrenForTreeController methods to each
class, to return the appropriate values.
You may also be able to work with NSTreeNode objects directly -- which
are used to represent the contents of an NSTreeController in 10.5 --
but unfortunately how to do so is still very sparsely documented.
(It's not clear to me whether you can just set the content of a tree
controller to a collection of NSTreeNode instances, for example.)
-- Chris
| Related mails | Author | Date |
|---|---|---|
| Adam Gerson | Mar 24, 00:55 | |
| Doug Knowles | Mar 24, 02:55 | |
| Chris Hanson | Mar 24, 03:08 | |
| Adam Gerson | Mar 24, 06:10 | |
| Adam Gerson | Mar 24, 06:20 | |
| Doug Knowles | Mar 24, 15:57 | |
| Adam Gerson | Apr 5, 20:33 | |
| Doug Knowles | Apr 5, 21:34 | |
| Andrew Merenbach | Apr 6, 04:02 |






Cocoa mail archive

