Hi everyone,

I have a Core Data model which consists of a simple tree of a particular entity, which has two relationships, parent and children. I have an NSTreeController managing the model, with an NSOutlineView bound to the NSTreeController.

This works fine if I set the fetch predicate of the NSTreeController in Interface Builder to "parent == nil".

My problem is that I need a single root object, but this should not display in the outline view, only its children should be displayed at the top level of the outline view. My entity has an attribute, isRootItem, that is true for the root item only.

For instance, my model looks like this:

Node 1
|
+-      Node 2
        |
        Node 3
        |       |
        |       +-      Node 5
        |
        Node 4

I need to display Nodes 2, 3 and 4 at the top level of the outline view, but still have their parent be "Node 1". Node 1 has a value of YES for isRootItem and all the others have NO.

If I set the fetch predicate of the tree controller to "parent.isRootItem == 1", this displays the tree correctly, but as soon as I add a new item to the top level it fails because the tree controller does not assign the "invisible" root item as the parent of the new item.

Is there an easy way to have the NSTreeController/NSOutlineView combination work in this situation? I'm considering moving to a datasource for the NSOutlineView if this isn't easily possible.

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to