Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > understanding NSOutlineView...

understanding NSOutlineView...
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Dec 17, 2003, 03:07 PM
 
I can't seem to grasp how NSOutlineView works. I understand NSTableView but can't understand how to code the datasource methods of NSOutlineView.

What I am trying to display in a NSOutlineView
is an array of Labs. Each entry in the array which is a lab has also an array or dictionary that is of 5 items (basically 5 children)

The example that I have seen mostly has been one with a single parent root. I need to show my data structure in the similar fashion as seen in System Profiler where "hardware" and "software" are on the same top level.

I don't understand how and what is (id)item and how identifying it if it nil that I return the root and if not nil then the children?

Any tips on how to code the datasource methods based on my data structure would be appreciated....

I looked at the developer examples and I'm still scratching my head...

Thanks...
     
Mac Elite
Join Date: Nov 2003
Location: Minnesota
Status: Offline
Reply With Quote
Dec 17, 2003, 11:09 PM
 
If I were you, I would go to the following link and do a search for NSOutlineView.

http://cocoa.mamasam.com/

There will no doubt be a ton of information and code-snippets. Good luck!
     
Dedicated MacNNer
Join Date: May 2002
Location: UK
Status: Offline
Reply With Quote
Dec 20, 2003, 04:59 PM
 
I got it by downloading this:

http://www.bignerdranch.com/Resources/outline.tgz

To display something other than the single root node at the top level, you need to change the following two methods:

Code:
- (id)outlineView:(NSOutlineView *)ov child:(int)index ofItem:(id)item - (int)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item
In either of them, when item == nil, you need to return the child or count of the node you want to appear as top level

Here's a modified version of the one from Big Nerd Ranch that does what I'm talking about:

http://www.doublemattress.com/upload...w_modified.tgz

In my modified version, I also edited the addChild method so that I could add to the root node without selecting it

-mrwalker
     
Dedicated MacNNer
Join Date: May 2002
Location: UK
Status: Offline
Reply With Quote
Dec 21, 2003, 07:45 AM
 
Originally posted by macaroni:

I don't understand how and what is (id)item and how identifying it if it nil that I return the root and if not nil then the children?
To Clarify, (id)item is a pointer to the item that the represents a line in the outlineview. This method is called once for each line. When it asks for item == nil, it is asking for the first item in the table
     
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Dec 24, 2003, 12:15 AM
 
Thanks a bunch mrwalker.

Your example was great and very straightforward. It highly resembled the overall structure of the objects and data that I needed to show.

Thanks again!!!!


Originally posted by mrwalker:
I got it by downloading this:

http://www.bignerdranch.com/Resources/outline.tgz

To display something other than the single root node at the top level, you need to change the following two methods:

Code:
- (id)outlineView:(NSOutlineView *)ov child:(int)index ofItem:(id)item - (int)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item
In either of them, when item == nil, you need to return the child or count of the node you want to appear as top level

Here's a modified version of the one from Big Nerd Ranch that does what I'm talking about:

http://www.doublemattress.com/upload...w_modified.tgz

In my modified version, I also edited the addChild method so that I could add to the root node without selecting it

-mrwalker
     
Dedicated MacNNer
Join Date: May 2002
Location: UK
Status: Offline
Reply With Quote
Dec 26, 2003, 09:14 AM
 
Originally posted by macaroni:
Thanks a bunch mrwalker.

Your example was great and very straightforward. It highly resembled the overall structure of the objects and data that I needed to show.

Thanks again!!!!
I feel all warm inside after that

-mrwalker
     
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Dec 28, 2003, 08:53 PM
 
Hi mrwalker,

I started playing around with NSOutlineView and I can display the top nodes fine. However when i click the disclosure triangles none of the children are shown.

I can't seem to figure out why.. I've stepped through my code and notice in comparison to your example that when the disclosure triangle is clicked in your example, the method
- (id)outlineViewNSOutlineView *)ov childint)index ofItemid)item is called. My test example it is not called....

The objects that I am trying to display is relatively simple; all nodes (including the rootNode) is a NSDictionary that holds a NSString forKey of "rootName" and a NSMutableArray forKey of "sevenDaySchedules"

So when the data is displayed in the outline view I want it to look as so:

\/ Schedule 1
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
> Schedule 2

But I can't seem to get the children to show.

Any tips would be appreciated.

Thanks.


Originally posted by mrwalker:
I feel all warm inside after that

-mrwalker
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:34 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2