Re: Editing NSOutlineView Group Item
Re: Editing NSOutlineView Group Item
- Subject: Re: Editing NSOutlineView Group Item
- From: Quincey Morris <email@hidden>
- Date: Mon, 03 Nov 2014 04:53:26 +0000
On Nov 2, 2014, at 20:18 , Luther Baker <email@hidden> wrote:
>
> So, before we get to the 'group' question - I seem to be having some
> difficulty with the item specific API. If I change the call from reloadData
> to reloadItem ... and if we consider reloading the selected row ... then:
>
> [outlineView reloadItem:selectedObject reloadChildren:YES or NO];
>
> invokes (in order)
>
> [outlineView:ov isItemExpandable:selectedItem]; /// return NO, bcs it
> is a leaf
> outlineView:ov child:1 ofItem:nil /// return selectedItem ... bcs it is
> the one we are reloading
> outlineView:ov isItemExpandable:selectedItem /// NO, bcs it is a leaf
>
> done .... nothing happens, no refresh
I can’t tell what’s happening because this isn’t real code. (Is ‘selectedObject’ meant to be the same thing as ‘selectedItem’, or is there some confusion between items and other objects in your data model? Surely you don’t “return selectedItem”, you just mean you return the item that is supposedly the same as the one you previously selected? This is all so approximate it’s hard to know how to interpret what you say.)
However, something looks wrong here. If “selectedItem” is “the one we are reloading” and that’s “child 1: ofItem: nil”, then the item you’re talking about (presumably) is the group row, and so it surely isn’t a leaf (even if it currently has 0 children). That is, if the children of item ‘nil’ are leaves, then you don’t have a hierarchical view.
So I think you have your conceptualization of the top levels of the hierarchy wrong. I know from experience that this is easy to fall foul of.
> when I instead use
>
> outlineView reloadDataForRowIndexes:columnIndexes /// it works
But listen to the advice you’ve been given. Using random NSTableView methods with an NSOutlineView is going to get you into trouble. Don’t waste your time “comparing” this with the correct outline view methods, just use the correct ones.
> Other people have had a similar experience ...
> http://stackoverflow.com/questions/19963031/nsoutlineview-reloaditem-has-no-effect <http://stackoverflow.com/questions/19963031/nsoutlineview-reloaditem-has-no-effect>
> but I'm afraid we must be missing something.
The fact is that NSOutlineView is used in a lot of apps by a lot of developers, and has been so used in all of its iterations over the years. The idea that there’s something buggy in NSOutlineView should be the *last* possibility you should be considering. It is vastly more likely that your code is just plain wrong.
Further, it isn’t useful to try to deduce what NSOutlineView is doing internally from the sequence of delegate calls. Again from experience, I can tell you that its behavior is deeply and asynchronously separate from the API. It’s better to think locally here. You are almost certainly returning the wrong thing from one of the delegate methods. Or perhaps you are mis-tracking the selected item.
_______________________________________________
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