Hi there, I've been having intermittent unexplained out of bounds errors when inserting new items into an NSOutlineView.
Here's a snippet from my controller's update method (triggered by a KVO notification) that should explains the sort of problem I've been having. This class it's from is the delegate and data source for the outline view. if ([insertedSet count] > 0) { NSIndexSet* insertedIndexes = [newContentArray indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) { return [insertedSet containsObject:obj]; }]; NSLog(@"%d", (int)[self outlineView:_outlineView numberOfChildrenOfItem:parentItem]); // => 1 NSLog(@"%@", insertedIndexes); // => { 1 } [_outlineView insertItemsAtIndexes:insertedIndexes inParent: parentItem withAnimation:NSTableViewAnimationSlideDown]; // => Exception here } The exception I'm getting is "NSOutlineView error inserting child indexes <NSIndexSet: 0x1018e3bf0>[number of indexes: 1 (in 1 ranges), indexes: (1)] in parent 0x101850920 (which has 0 children)". So it looks like NSOutlineView's internal state is somehow getting out of sync with my controller class. I think I have it tracked down to the fact that I didn't want the first bunch of content displayed to animate in, so I had the following at the beginning of the method: if (_flags.isSettingContent) { [_outlineView reloadItem:parentItem]; return; } Replacing it with: if (_flags.isSettingContent) { [_outlineView insertItemsAtIndexes:insertedIndexes inParent:parentItem withAnimation:NSTableViewAnimationEffectNone]; return; } seems to fix the problem. Problem is, I'm not sure why it fixes it... A simple test case didn't seem to reproduce the issue. Has anyone noticed any differences in behaviour between these two ways of updating an outline view? Thanks Chris _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com