Re: Completely remove a window (from NSApp)?
Re: Completely remove a window (from NSApp)?
- Subject: Re: Completely remove a window (from NSApp)?
- From: PGM <email@hidden>
- Date: Wed, 27 Dec 2006 21:59:46 -0500
But indeed, if I -setReleasedWhenClosed:YES, and then -close a
window, it is
instantly removed from -[NSApp windows]. So, apparently
-setReleasedWhenClosed is the magic behind NSApp removing a
document; a more
accurate name would be -removeFromNSAppWhenClosed. But I'm fine
with magic
as long as it works :) This works in an NSWindowController
category or
subclass:
I made a little test-project and it seems that the magic is not so
much in -setReleasedWhenClosed itself, but simply in releasing the
instance of NSWindow. As soon as a window is initialised, it will
show up in [NSApp windows] even if it is doing nothing but sitting
unused in a nib file and is never actually shown. The window will
only disappear from NSApp's list once it is released. So your -
removeWindow method will not work unless you are sure that the window
is not retained elsewhere.
If I recall correctly, for document windows normally
NSWindowController takes care of releasing the window it manages, so
that when a NSDocument instance releases its windowControllers, the
windowControllers release their windows. So you probably hacked your
NSDocument subclass in such a way that this does not happen anymore.
Cheers, Patrick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden