Restoring a NSTreeController selection
Restoring a NSTreeController selection
- Subject: Restoring a NSTreeController selection
- From: Markus Spoettl <email@hidden>
- Date: Wed, 23 Jun 2010 20:43:15 -0400
Hi List,
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.
I'm pretty sure I'm overlooking something so I'm hoping someone can give me a hint on how to do that in a more elegant fashion. Thanks in advance!
Regards
Markus
PS: I can't store the index paths for the selection and restore those because the model may change between save and restore and so the index paths would no longer be the same.
--
__________________________________________
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