Re: Deferring creation of children when using bindings?
Re: Deferring creation of children when using bindings?
- Subject: Re: Deferring creation of children when using bindings?
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Oct 2013 14:12:08 -0700
On Oct 14, 2013, at 1:33 PM, Rick Mann <email@hidden> wrote:
> I have a tree controller bound to an array in my window controller. I populate it with top-level items, and they show up, but I'd like to defer populating the children of each item until the user actually clicks the disclosure triangle. Getting the children is time-consuming and expensive. Is there a way I can get it to show the disclosure triangle and then call me back when it's clicked open?
In your model class implement a boolean property that returns YES for a leaf, and set that as the NSTreeController’s leafKeyPath. Then the controller will just call that for closed items and draw the disclosure triangles for items where it returns NO.
Then you’re free to make the children and (optionally) count properties compute the children lazily, because they won’t be called until the item is flipped open in the UI.
—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