NSTreeController: how do I select a model object?
NSTreeController: how do I select a model object?
- Subject: NSTreeController: how do I select a model object?
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Oct 2013 14:18:19 -0700
Hey, Rick’s tree controller question reminded me that I’ve got one I’ve been meaning to ask:
With an NSOutlineView driven by an NSTreeController, I’m having trouble figuring out how to programmatically select an item: given one of my model objects, how do I tell the controller or view to select it?
NSTreeController has a .selectedObjects property, which is great for _getting_ the selection, but for some reason it’s a read-only property (unlike in NSArrayController), so I can’t use it to _set_ the selection.
But if I go through the outline view, its ‘item’ objects are the NSTreeNodes managed by the controller, not my model objects, and I don’t see any clean way to map from a model object to its tree node. It seems like I’d have to write a recursive function to search the entire NSTreeNode hierarchy for one whose representedObject is my model object. Surely that can’t be the only way to do this?
—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