Re: NSOutlineView blowing stack
Re: NSOutlineView blowing stack
- Subject: Re: NSOutlineView blowing stack
- From: Allan Odgaard <email@hidden>
- Date: Fri, 20 Feb 2004 01:24:08 +0100
On 20. Feb 2004, at 1:09, Tom Harrington wrote:
Yes-- I'm tagging each child with a pointer to its parent. The
outline column has a checkbox in it, and clicking the checkbox in one
item may affect the parent item's checkbox state.
Generally I avoid parent pointers -- I have a function which return an
array of parent pointers for a given item which is O(n) rather than
O(1), but I think it is a worthy trade-off due to the simplified
administration of nodes.
That would seem to be the case, and I suppose collapsing all items
avoids doing such a comparison on an item with a parent reference. I
feel like I'm walking on thin ice here. :-/
A quick fix is to wrap the parent pointers with a NSValue, using
valueWithPointer: and pointerValue to store/retrieve the actual
pointer.
Btw: another problem with cyclic data is that you are causing a
retain loop, and thus the data will never be released (because
children retain parents, so neither will ever get a retain count of
zero). Though it shouldn't crash ;)
Yeah, I'm aware of that risk.
Just to be sure: this is not a risk, this is a guarantee (that the
items will never be freed, unless you manually remove all the parent
pointers).
Kind regards Allan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.