Re: Implementing NSOutlineView datasource methods when using an asynchronous source?
Re: Implementing NSOutlineView datasource methods when using an asynchronous source?
- Subject: Re: Implementing NSOutlineView datasource methods when using an asynchronous source?
- From: Jens Alfke <email@hidden>
- Date: Thu, 4 Feb 2010 17:29:25 -0800
On Feb 4, 2010, at 5:12 PM, Laurent Daudelin wrote:
> Just wondering, what kind of design someone acting as a datarsource for an NSOutlineView choose when the source of the data to be displayed is provided by some asynchronous means? What do you return in methods like 'outlineView:numberOfChildrenOfItem:' when the data hasn't been fetched yet?
If you don't know the number yet, return zero, and kick off an async request to get the children (or at least the number of them.)
When you find out the number of children, tell the outline view to reload the parent item and its children.
The best way to handle getting the children is to return a placeholder object for any child you don't have info for yet, and then make sure you've requested info for that child (you can collect these into batches and request a range of children, if the protocol supports that.) Then when you receive child info, tell the outline to reload the items for those children.
—Jens_______________________________________________
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