setMenu: nil does not release a menu ?
setMenu: nil does not release a menu ?
- Subject: setMenu: nil does not release a menu ?
- From: Tobias Hermann <email@hidden>
- Date: Thu, 22 May 2003 16:34:00 +0200
hi!
I am experimenting with NSMenus.
I experienced a very strange behavior:
Consider aMenu as a ready configured NSMenu, aView as some NSView
subclass.
[aView setMenu: aMenu]; does retain the menu, that is what I would
expect, and it is ok.
But:
[aView setMenu: nil]; does NOT release aMenu again.
Is this normal ? I get unwanted memory leaks that way! I want to
release my menu properly when I don't need it anymore!
I even think that [aView release]; (assuming it is the final release
that brings a aView dealloc with it) also does not release aMenu again
(when having set aView's menu to aMenu before).
Any ideas?
Thanx!
Tobi
ps: By the way. When creating such a menu in Interface builder, every
menu Item added within IB increases the menu's retain count by one. Why
is that?
When I programmatically add menu Items, the menu does NOT get retained.
Consider a NSMenu built in IB. It has 4 menu items. After awakeFromNib,
the menu's retain count is 5. (4 uneseccary retains from the items).
The joke is: If you call removeItemAtIndex in order to remove the
items, the menu does NOT get released...
Something is going wrong there... Or I really did understand something
totally wrong :-(
_______________________________________________
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.