RE: NSView subclass never gets dealloced?
RE: NSView subclass never gets dealloced?
- Subject: RE: NSView subclass never gets dealloced?
- From: "Thomas A. Rieck" <email@hidden>
- Date: Fri, 29 Mar 2002 12:46:04 -0500
I believe I had the same problem before. Did you check "Release When
Closed" in Interface Builder for the parent NSWindow?
Tom Rieck
-----Original Message-----
From: email@hidden
[
mailto:email@hidden]On Behalf Of Brock Brandenberg
Sent: Friday, March 29, 2002 12:28 PM
To: email@hidden
Subject: Re: NSView subclass never gets dealloced?
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.
_______________________________________________
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.