Re: (no subject) - NSOutlineView
Re: (no subject) - NSOutlineView
- Subject: Re: (no subject) - NSOutlineView
- From: Orr Philip <email@hidden>
- Date: Sat, 17 Mar 2007 12:29:50 +0000
Okay then, this is starting to make more sense to me now.
When the computer asks for "-outlineView:child:ofItem:", do you pass
it the items address whether its an NSString or NSArray or whatever,
and it uses this as an id which it then passes to
"outlineView:objectValueForTableColumn:byItem", I think. If this is
the case then how do you know what the item is relating to, NSString,
customArray, or whatever.
Phil
On 17 Mar 2007, at 00:32, Nick Zitzmann wrote:
On Mar 16, 2007, at 6:01 PM, Orr Philip wrote:
If I've got an array of objects to be displayed and one of those
is an array of more objects, clicking on the arrow to the left
reveals a list of those said objects but how does the application
know what values it is being asked to display.
The key difference between NSOutlineView and NSTableView is while
NSTableView deals with row indices, NSOutlineView displays "items"
in each row. An item can be whatever you want it to be - NSStrings,
NSArrays of NSStrings, custom objects, or a combination of objects
of different classes. The only catch is an item can appear only
once in the view.
The three key data source methods are:
-outlineView:child:ofItem: (returns the child item of a parent
item; if the parent item is nil then it's asking for root items)
-outlineView:numberOfChildrenOfItem: (returns the number of
children of an item, if any; if the parent item is nil then it's
populating the root, like -numberOfRowsInTableView:)
-outlineView:objectValueForTableColumn:byItem: (this is just like
the NSTableView -tableView:objectValueForTableColumn:... data
source method)
So, if you have an item that is an NSArray, and the user expands
it, the view first calls -outlineView:numberOfChildrenOfItem:, and
your app would probably return [item count] in this case. Then -
outlineView:child:ofItem: is called, and you return the object at
the given index in the NSArray. Finally, -
outlineView:objectValueForTableColumn:byItem: is called, and there
the app returns the object that actually gets displayed.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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