Issue with -[NSOutlineView autosaveExpandedItems]
Issue with -[NSOutlineView autosaveExpandedItems]
- Subject: Issue with -[NSOutlineView autosaveExpandedItems]
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 10 Jul 2014 16:20:53 -0400
This question has been asked several times over the last few years, but I haven't found a useful answer in all the discussions.
How can I make an outline view reinstate the expanded and collapsed state of its rows across application launches?
Building in Xcode 5.1.1 under OS X 10.9.4 Mavericks, I select the outline view nib file's Autosave checkbox for Autosave Expanded Items, which is equivalent to calling -setAutosaveExpandedItems:YES.
I also implement the outline view data source method -outlineView:persistentObjectForItem: by returning -[NSKeyedArchiver archivedDataWithRootObject:item] and the data source method -outlineView:itemForPersistentObject: by returning -[NSKeyedUnarchiver unarchiveObjectWithData:object]. Doing this is the only sense I can make of the very cryptic reference document instructions, and this solution is echoed in some of the mailing list discussions I found.
It works, up to a point. When I launch the application, NSLog calls tell me that it does call -outlineView:itemForPersistentObject: at launch on the archived objects for every row that I left expanded when I previously quit. I see the correct archived data items in my user defaults preferences file, so I know the application properly called -outlineView:persistentObjectForItem: when I previously quit. The archived data items unarchive correctly to the outline view items that were left expanded when I previously quit.
However, the indicated rows are not expanded at launch. Instead, all rows are collapsed at launch.
Has anybody made this work? How?
--
Bill Cheeseman - email@hidden
_______________________________________________
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