On Jul 18, 2014, at 3:12 PM, Ken Thomases <[email protected]> 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 protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to