I have found and reported another bug in the -[NSOutlineView autosaveExpandedItems] mechanism. Here is a brief summary of my bug report #17728176:
Summary: In NSOutlineView, setting autosaveExpandedItems to YES is supposed to cause the outline to remember the expanded/collapsed state of its rows across application launches. The documentation points out that it does this only if you implement the -persistentObjectForItem: and -itemForPersistentObject: NSOutlineViewDataSource methods. This mostly works correctly, but there is one case where expanding or collapsing rows fails to call -persistentObjectForItem: and throws the autosaveExpandedItems mechanism into an inconsistent state. Specifically, the NSOutlineView reference document says the following with respect to the item parameter of -[NSOutlineView expandItems:expandChildren:]: "Starting in OS X version 10.5, passing 'nil' will expand each item under the root in the outline view." It does expand each item as stated, but it does NOT call the -persistentObjectForItem: datasource method, and as a result the expanded state of all rows is not reinstated after quit and relaunch. The only way to get an "expand all" button or menu item to persist across relaunches is to expand each item individually in a loop, something like this:: - (IBAction)expandAllRows:(id)sender { AWRSourceListOutlineView *outlineView = [self sourceListOutlineView]; NSIndexSet *topLevelItemIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[self sourceListContents] count] - 1)]; [topLevelItemIndexes enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger itemIndex, BOOL *stop) { [outlineView expandItem:[[self sourceListContents] objectAtIndex:itemIndex] expandChildren:YES]; }]; // This alternative does not trigger the -[NSOutlineViewDataSource persistentObjectForItem:] datasource method; bug in OS X 10.9.4 Mavericks. // [[self sourceListOutlineView] expandItem:nil expandChildren:YES]; } -- Bill Cheeseman - b...@cheeseman.name _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com