Hi All,

I am working on integrating a NSOutlineView and NSTreeController into my application and have bumped into some problems related to objects not being release when remove from the NSTreeController.

I have boiled the problem down to the following very basic setup - working in a non-gc'ed environment in snow-leopard:

1) I have created a very simple document based application where a document contains one instance variable of type NSMutableArray for holding instances of a class 'Node' which has no instance variables and only implements a 'children' method which returns an empty NSMutableArray hence they are all leafs.

2) My NIB file for the document contains an NSTreeController whose content array is bound to the NSMutableArray in my document.

3) My view holds one NSOutlineView with one column which draws its content from the NSTreeControllers arrangedObjects.

4) Finally the window contains two buttons - one which is attached the the NSTreeControllers add:sender action and the other to remove:sender.

-So far so good - I am able to add and remove elements to the documents' mutable array member and have them displayed in the treeview.

What troubles me is that the 'Node" objects added via the controller add:sender method dont get dealloced when removed via the remove:sender method.

Node objects added has a retain count of 2 which makes good sense - one reference from the document NSMutableArray instance and one from internal controller reference.

However, when I want to remove and element by sending the remove:sender message to the arraycontroller, the retainCount of the node objects only go down to 1 and the objects are hence never dealloc'ed.

I would expect that using such "boiler plate" code would clean up after itself - just as is the case if I use an NSArrayController - and correctly manage objects created and deleted directly via the controller.

Am I missing something here or is this a bug in the NSTreeController? - Hopefully not the last as it properly doesnt get any simpler than this scenario.

Thanks in advance
Mads
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to