Populating tree control programatically

Discussion in 'Mac Programming' started by McBgnr, Apr 21, 2009.

  1. McBgnr macrumors regular

    Apr 13, 2009

    i want to populate three control programatically. I checked the documentation for NSTreeController... there are methods like add, addchild available with it. But these are all actions, which will be called from the UI.

    But I want to make tree control programatically. It can have any number of levels and nodes.

    Suggestions are welcome.
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Do you know how to work with an NSArrayController? If not, I would suggest learning how to use that with an NSTableView first. Knowing how those work together will make understanding NSTreeController/NSOutlineView much easier.
  3. garethlewis2 macrumors 6502

    Dec 6, 2006
    Strange, I used google with the search pattern

    NSTreeController tutorial, and it found me one.

    What did you enter in google?
  4. kainjow Moderator emeritus


    Jun 15, 2000
    If you're referring to this, that tutorial is outdated, incomplete and 31 pages! That's a little overkill for a single class.

    I just whipped up a demo project of NSTreeController without using it at all before in about 5 minutes. I would suggest to McBgnr or anyone else wanting to learn how to use NSTreeController to first learn how to use NSArrayController, and then read up on Apple's docs on NSTreeController. If you want a better understanding learn how to use NSOutlineView with the datasource/delegate also (which IMO is easier to understand than NSTreeController since there's less "magic" going on).

Share This Page