Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Completely remove a window (from NSApp)?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Completely remove a window (from NSApp)? (From: Jerry Krinock <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.