• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTreeController: how do I select a model object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSTreeController: how do I select a model object?
      • From: Mike Abdullah <email@hidden>
    • Re: NSTreeController: how do I select a model object?
      • From: Sean McBride <email@hidden>
    • Re: NSTreeController: how do I select a model object?
      • From: Michael Babin <email@hidden>
    • Re: NSTreeController: how do I select a model object?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: This document’s file has been changed by another application since you opened or saved it.
  • Next by Date: Re: NSTreeController: how do I select a model object?
  • Previous by thread: Re: Deferring creation of children when using bindings?
  • Next by thread: Re: NSTreeController: how do I select a model object?
  • Index(es):
    • Date
    • Thread