 |
 |
understanding NSOutlineView...
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2002
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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)outlineView  NSOutlineView *)ov child  int)index ofItem  id)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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |