Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: [NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded)



Here's what I do:

@"isExpanded" is a persistent attribute of my model objects.

In the delegate

- (void)outlineViewItemDidExpand:(NSNotification *)notification;
{
[[[[notification userInfo] valueForKey:@"NSObject"] representedObject] setValue:[NSNumber numberWithBool:YES] forKey:@"isExpanded"];
}


- (void)outlineViewItemDidCollapse:(NSNotification *)notification;
{
[[[[notification userInfo] valueForKey:@"NSObject"] representedObject] setValue:[NSNumber numberWithBool:NO] forKey:@"isExpanded"];
}


In an NSOutlineView subclass

- (void)reloadData;
{
	[super reloadData];
	NSUInteger row;
	for (row = 0 ; row < [self numberOfRows] ; row++) {
		NSTreeNode *item = [self itemAtRow:row];
		if ([[item representedObject] isMemberOfClass:[ESGroupNode class]])
			if ([[[item representedObject] valueForKey:@"isExpanded"] boolValue])
				[self expandItem:item];
	}
}


works like a charm

Jon

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >[NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded) (From: Stéphane Sudre <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.