On 2013 Sep 13, at 12:11, Kyle Sluder <k...@ksluder.com> wrote: > Add a property to your app delegate that retains the window controller.
> Have your window controller listen for NSWindowDidCloseNotification from > its window, and send a message to the app delegate. In response to this > message, the app delegate should release the window controller (probably > by assigning its property to nil). That is good, and I've done it that way. But my app delegates get so damned long, so last year I put that boilerplate delegation and notification observing code into a subclass of NSWindowController. In cases where you can live with that (no multiple inheritance), and want to have only one window of a given class (a Preferences window, for example), it "works for me". To add a new "self-releasing" window to your project, 3 steps… • Make the new FooWindowController a subclass of SSYTempWindowController. • In FooWindowController, override +nibName. • To display the window, +[FooWindowController showWindow]. That's all. It loads the nib, shows the window, and all goes away when the user closes it. SSYTempWindowController.m is 62 lines including whitespace… https://github.com/jerrykrinock/ClassesObjC/blob/master/SSYTempWindowController.m _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com