Re: NSView subclass never gets dealloced?
Re: NSView subclass never gets dealloced?
- Subject: Re: NSView subclass never gets dealloced?
- From: Brock Brandenberg <email@hidden>
- Date: Fri, 29 Mar 2002 11:27:42 -0600
Hi Nick.
The dealloc routine for the superview is where the release would occur.
The alloc, init and addSubview: will occur in the superview's
initBlahBlahBlah: or awakeFromNib: method and the release will occur in
the superview's dealloc routine. But if the dealloc never gets called,
the subViews never get released.
Is the behavior I'm seeing to be expected? Seems fishy to me.
Maybe you made something like this:
MyView *myView = [[MyView alloc] init....]
[someOtherView addSubview:myView];
Now you have to release myView, because adding a subview increases the
retain count (think of it like adding myView to an NSArray).
Regardless, Cocoa should be smart enough to decrement retain counts and
release allocated objects in the view hierarchy. I can understand this
not being possible for other object subclasses because Cocoa would have
no knowledge of who depends on who - it's just the equivalent of a bunch
of malloc's and free's. But view hierarchy subclasses? Cocoa knows the
complete view hierarchy and the kind of subclass added to any view as a
subview. Using addSubview is really no different than dragging a custom
NSView subclass into another view in IB, is it? It seems odd that Cocoa
would say, "Screw it... I'm out of here" and just exit to shell without
tearing down the view hierarchy.
Brock Brandenberg
----- industrial design @ bergdesign.com ------
_______________________________________________
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.