• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Another -[NSOutlineView autosaveExpandedItems] bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another -[NSOutlineView autosaveExpandedItems] bug


  • Subject: Re: Another -[NSOutlineView autosaveExpandedItems] bug
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 18 Jul 2014 14:12:30 -0500

Setting aside the NSOutlineView bug you're describing, there are issues with your code:

On Jul 18, 2014, at 1:19 PM, Bill Cheeseman <email@hidden> wrote:

> - (IBAction)expandAllRows:(id)sender {
>    AWRSourceListOutlineView *outlineView = [self sourceListOutlineView];
>    NSIndexSet *topLevelItemIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[self sourceListContents] count] - 1)];

This leaves out the index of the last item.  A range consists of a starting index and a length, _not_ the last index.  Count - 1 would be appropriate for a last index, but not for a length of a range that encompasses the last index (assuming starting at 0).

>    [topLevelItemIndexes enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger itemIndex, BOOL *stop) {
>        [outlineView expandItem:[[self sourceListContents] objectAtIndex:itemIndex] expandChildren:YES];
>    }];

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];
    }];

Even if I've misunderstood and you're deliberately skipping the last element, it's probably cleaner to do that with the above with an added check on the idx parameter.

Regards,
Ken


_______________________________________________

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


  • Follow-Ups:
    • Re: Another -[NSOutlineView autosaveExpandedItems] bug
      • From: Bill Cheeseman <email@hidden>
    • Re: Another -[NSOutlineView autosaveExpandedItems] bug
      • From: Bill Cheeseman <email@hidden>
References: 
 >Another -[NSOutlineView autosaveExpandedItems] bug (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Another -[NSOutlineView autosaveExpandedItems] bug
  • Next by Date: Re: Another -[NSOutlineView autosaveExpandedItems] bug
  • Previous by thread: Another -[NSOutlineView autosaveExpandedItems] bug
  • Next by thread: Re: Another -[NSOutlineView autosaveExpandedItems] bug
  • Index(es):
    • Date
    • Thread