Re: Window controllers and memory leaks
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