• 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: Kyle Sluder <email@hidden>
  • Date: Fri, 13 Sep 2013 12:11:51 -0700

On Fri, Sep 13, 2013, at 09:12 AM, Jonathan Taylor wrote:
> I want to allocate a window + controller, and I want it to live until the
> user closes the GUI window, at which point I want it to disappear and
> clean up after itself. I believe that the following code does not leak
> memory and behaves as intended.

Don't do this. Experience has taught us that apps are more stable when
developers don't make exceptions to the standard memory management
rules.

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).

--Kyle Sluder
_______________________________________________

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>)

  • Prev by Date: Re: Helper tool
  • Next by Date: Re: ARC vs Manual Reference Counting
  • Previous by thread: Re: Window controllers and memory leaks
  • Next by thread: Re: Window controllers and memory leaks
  • Index(es):
    • Date
    • Thread