• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Window controllers and memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window controllers and memory leaks


  • Subject: Re: Window controllers and memory leaks
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 14 Sep 2013 10:28:34 -0700

On 2013 Sep 13, at 12:11, Kyle Sluder <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Window controllers and memory leaks
      • From: Jerry Krinock <email@hidden>
References: 
 >Window controllers and memory leaks (From: Jonathan Taylor <email@hidden>)
 >Re: Window controllers and memory leaks (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Save Panel without Filename selection
  • Next by Date: Need calls for MathType Edit Interface
  • Previous by thread: Re: Window controllers and memory leaks
  • Next by thread: Re: Window controllers and memory leaks
  • Index(es):
    • Date
    • Thread