Re: NSWindow alloc/dealloc problems
Re: NSWindow alloc/dealloc problems
- Subject: Re: NSWindow alloc/dealloc problems
- From: j o a r <email@hidden>
- Date: Mon, 29 Nov 2004 18:19:49 +0100
On 2004-11-29, at 18.02, Alex Reynolds wrote:
The content view (targetDisplayCino) is from an NSPanel. It appears
that I do not need to do this:
targetDisplayCino = [[NSPanel alloc] init];
Do you know that NSPanel is a subclass to NSWindow?
because it appears to be created and destroyed with the application as
a whole.
Created with the application? Destroyed it will be, as any object that
you create in the application will be removed when the application is
terminated.
Does a [NSWindow close] or [NSWindow release] call attempt to destroy
everything inside it? I just want the NSWindow instance to go away,
not my NSView or NSPanel.
-[NSWindow close] and -[NSObject release] are very different methods.
You need to understand what they do, how and why they differ. Neither
of them, on their own, triggers the deallocation of anything. If you've
set the window to be "released on close", calling close will trigger a
release. If a call to release triggers the window to deallocate, the
window will in turn release it's view hierarchy, most often triggering
it to be deallocated in turn.
Here is the entire method I use that handles alternate presses of the
"capture" button.
I'm not quite sure that I understand why you assign the content view to
the window like that. It does, in any case, seem to be the root of the
problem - as you appear to only create the content view once. If you
want to re-use it between your calls to this method, you need to add a
reference to it and retain it, so that you can hold on to it when it's
enclosing window is deallocated (but why deallocate the window if you
plan to open it again?).
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden