Re: Restoring a NSTreeController selection
Re: Restoring a NSTreeController selection
- Subject: Re: Restoring a NSTreeController selection
- From: Markus Spoettl <email@hidden>
- Date: Thu, 24 Jun 2010 10:36:20 -0400
On Jun 24, 2010, at 4:35 AM, email@hidden wrote:
>> I have a NSOutlineView bound to a NSTreeController that delivers my model objects. That NSTreeController sorts the model objects through sort descriptors. What I would like to do is save the current selection and restore it at a later time.
>>
>> Saving is easy, I get the -selectedObjects from the tree controller, extract my model objects and store a unique key that allows me to identify the objects when I look them up later.
>>
>> Restoring proves to be tricky - for me anyway. I can locate my model objects properly and build an index path for each one I want to select. However, the index paths the tree controller seems to expect is the one AFTER applying the sort order.
>>
>> My model is not sorted in the same way the tree controller's representation is. The only I can find out the correct (for selection) index paths is to sort my model like the tree controller does and find the index paths after that. That's terribly inelegant and potentially expensive. I think the tree controller should either accept -selectionIndexPaths the way I see them in my model OR let me see the ordered collection of how my model ended up being represented.
>>
>>
> Maybe you know all this but:
>
> 1. NSTreeController items are subclasses of NSTreeNode (see the 10.5 release notes).
I was deterred to do this after reading this in the documentation for -arrangedObjects
-----
Special Considerations
Prior to Mac OS X v10.5 this method returned an opaque root node representing all the currently displayed objects. This method should be used for binding, no assumption should be made about what methods this object supports.
-----
I feel a little stupid as it's obviously referring to prior 10.5, although the language could be clearer.
Thanks all for your help!
Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________
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