Re: NSOutlineView woes
Re: NSOutlineView woes
- Subject: Re: NSOutlineView woes
- From: Graham Cox <email@hidden>
- Date: Wed, 23 Mar 2016 10:02:25 +1100
> On 21 Mar 2016, at 5:02 PM, Quincey Morris <email@hidden> wrote:
>
> On Mar 20, 2016, at 20:20 , Graham Cox <email@hidden> wrote:
>>
>> This is driving me insane!
>
> a. Can you produce a test project that demonstrates the behavior? (Preferably not via drag-and-drop, since that’s so much harder to debug.)
>
> b. It’s not the actual problem, but I wonder why you construct the needed parent-relative index set by using ‘rowForItem:’? I may be wrong, but I don’t think we can assume that NSOutlineView keeps references to all or any subset of the universe of items in the list, so it may have to walk the rows starting from the root item, and this certainly opens the possibility of dicey behavior if your data structures are in the process of being changed. I certainly wouldn’t assume it can find the row more efficiently than you can find the child index. Since you know the child, you know the parent, so you can find child index by iterating linearly through the parent’s children yourself.
>
> c. There’s also a logic issue here. It’s not clear whether you’re making a mistake, or the mistake is only an apparent consequence of the way you’ve described your methodology: It is incorrect, in general, to compute the child index by subtracting the child row from the parent row, because there may be intervening children which themselves have children.
>
Thanks for the help (on and off list) everyone - I managed to knock it into some sort of working shape.
In the end I was able to use the ‘move’ variant of the animation by setting a flag to supress the response to the delete/insert operations. This is admittedly a little hacky but does work in all the test cases I was able to dream up. I also simplified the code in a few places to not rely on assumed internal states of the outline view and things got better. Overall it’s probably not the perfect solution, but it works and allows me to move on to other problems.
—Graham
_______________________________________________
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