Re: Another -[NSOutlineView autosaveExpandedItems] bug
Re: Another -[NSOutlineView autosaveExpandedItems] bug
- Subject: Re: Another -[NSOutlineView autosaveExpandedItems] bug
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 18 Jul 2014 15:52:39 -0400
On Jul 18, 2014, at 3:12 PM, Ken Thomases <email@hidden> wrote:
> Is there a reason you didn't just directly enumerate the objects in the collection? Constructing an index set for all of the items, enumerating that, and then looking up the items by the index seems cumbersome.
>
> [[self sourceListContents] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
> [outlineView expandItem:obj expandChildren:YES];
> }];
Another lapse of attention on my part. I had been writing a similar method to enumerate selected rows, where using NSIndexSet is appropriate. I just grabbed the same code and stuck it in here. It worked, of course, but you're right that it was cumbersome. In addition, I don't need the NSEnumerationReverse option when enumerating items in the datasource instead of rows. Here's my final code:
- (IBAction)expandAllRows:(id)sender {
AWRSourceListOutlineView *outlineView = [self sourceListOutlineView];
NSArray *topLevelItems = [self sourceListContents];
[topLevelItems enumerateObjectsUsingBlock:^(id obj, NSUInteger itemIndex, BOOL *stop) {
[outlineView expandItem:obj expandChildren:YES];
}];
}
Thanks again. I don't know what I would do without you!
--
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