Re: [NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded)
Re: [NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded)
- Subject: Re: [NSOutlineView] Saving/Restoring the hierarchy disclosure state (Reloaded)
- From: Jonathan Dann <email@hidden>
- Date: Thu, 26 Jun 2008 19:29:48 +0100
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