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

Reply via email to