On Oct 14, 2013, at 1:33 PM, Rick Mann <[email protected]> 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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to