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
Delivered-to: email@hidden
Delivered-to: email@hidden
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=8E1Ro/3Owqc0huLL8QLC5Rds6LRPZ7oSKruWT035sTg=; b=BR7v0JeQ6HOtA5dsVoegmWTyOI4LL/6mtQYCTkvvEiciTqSJp/IXSvuPZSiqvRpSBO bXR3KD65vofWQlX6kiDZNDfkDW41JfpCarKA5ddWSq/JEfbX2lbs2HvZq+EAdc6QOBlq zdkdyjbpRVPRJnOw8I3MOh/T51CtteTx1lxyo=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=Qv+5QeVOvLrgpa7zOqffajzJjg6+nZ9afD9BrMI9fP9uRvJ1CDeld6E9dwoZ6shEHW 55PZbDqKbdC5WImMKcJ7l9Onq6PbvDMpdoteRXuNobwqAuXvaePVRUJ142j3++YwxHf7 POXWkancnCZ2ip2G7Ia4xcXopQ3xAqd0w5c2U=
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
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.