• 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: 'Static' items in an NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Static' items in an NSOutlineView


  • Subject: Re: 'Static' items in an NSOutlineView
  • From: Koen van der Drift <email@hidden>
  • Date: Sat, 15 Oct 2011 15:44:26 -0400

Thanks for the pointers. I also just found this sample code from Apple: ,http://developer.apple.com/library/mac/#samplecode/SidebarDemo/>

They don't use CoreData but I may be able to adapt it.

- Koen.


On Oct 14, 2011, at 2:51 PM, Quincey Morris wrote:

> On Oct 14, 2011, at 09:24 , Koen van der Drift wrote:
>
>> I’m trying to find out how to create the grayish, static items in an
>> NSOutlineView, eg “Library” in iTunes or “Mailboxes” in Mail.
>> Sometimes they have a disclosure triangle, eg "Devices" in the Finder.
>> I think I need to subclass NSCell to change the font, etc.
>
> Subclassing isn't necessary. This is how "group" rows appear in an outline view with the "source list" display style. You use delegate methods to customize the exact appearance: 'outlineView:isGroupItem:' indicates a group item; 'outlineView:shouldShowOutlineCellForItem:' suppresses the disclosure triangle on those rows. There may be other methods you need to use to get exactly the horizontal and vertical spacing of the iTunes list -- I forget the details.
>
>> But I am
>> not sure how to identify these, would an attribute “isStaticItem” for
>> my Group Entity or something like that be a good approach?
>>
>> Secondly, are they part of the NSOutlineView, and the underlying
>> NSTreeController and CoreData model?  Just like in the abovementioned
>> examples, these items are already present when the app is started up
>> the first time, so if they are part of the core data model, they must
>> be created programmatically at first, and become part of the model
>> once the user starts adding folders and items. So if the app doesn’t
>> find a database, it will create the starting list.  Again, is this the
>> correct approach?
>
> One way to do this is to set up an "intermediate" data model for your list, since the structure of the list doesn't match the structure of your actual data model. When I do this, I typically define a ListItem class -- a subclass of NSTreeNode is easiest, since you'll likely want to follow parent/child relationships for various reasons -- with a "representedObject" property that can be set to various things -- a string, for header items, or a Core Data object for detail rows.
>
> Thus you end up with a tree structure of ListItem objects, which you can then feed to the outline view either via your data source or via bindings.
>
> Incidentally, since this tree structure exists only to service the outline view, the proper place to create it is in the outline view's window's window controller. It's basically glue code, so you definitely don't want to expose it to the rest of your app.
>
>

_______________________________________________

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

References: 
 >'Static' items in an NSOutlineView (From: Koen van der Drift <email@hidden>)
 >Re: 'Static' items in an NSOutlineView (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Blocks vs. life, the universe and everything
  • Next by Date: Re: Does XCode 3.2 Documentation Browser Stink?
  • Previous by thread: Re: 'Static' items in an NSOutlineView
  • Next by thread: Re: 'Static' items in an NSOutlineView
  • Index(es):
    • Date
    • Thread