• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTreeController, Core Data and root objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController, Core Data and root objects


  • Subject: Re: NSTreeController, Core Data and root objects
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 5 Nov 2009 13:38:41 -0600

On 4 Nov 2009, at 9:15 PM, Rob Keniger wrote:

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.

Here is what I did, for a small tree: My document keeps the root object as a KVO property -- I do not rely on a fetch.


I declare classes for my tree-element entities. so I could implement a method, -(NSArray *)orderedChildren, to return the "children" set, sorted as needed.

I exposed the document (and thus, indirectly, the root) through an NSObjectController.

I bound the tree controller's content _array_ to that root object's orderedChildren key. (Document NSObjectController -> root.orderedChildren). Members of the content array appear as top- level nodes in the outline.

My tree has constant structure, so I can't make any comment on mutation.

I'm sorry I have trouble making bindings clear from text alone. And, my experience on this is shallow. I hope at least I've given you something you can use to explore.

	— F

_______________________________________________

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


  • Follow-Ups:
    • Re: NSTreeController, Core Data and root objects
      • From: Rob Keniger <email@hidden>
References: 
 >NSTreeController, Core Data and root objects (From: Rob Keniger <email@hidden>)

  • Prev by Date: Re: Status Bar App menu won't work in 10.6, will in 10.5
  • Next by Date: How to retrieve document type?
  • Previous by thread: NSTreeController, Core Data and root objects
  • Next by thread: Re: NSTreeController, Core Data and root objects
  • Index(es):
    • Date
    • Thread