Re: Release a NSWindowController after the window is closed

2011-06-19 Thread Marc Respass
Hi Roland, I don't follow you. You want to add MyWindowController *strongRefToKeepARCHappy and set it to [self retain]? I don't see an advantage to that. I suppose it would work but you'd want to give it a name like I did or include a comment for why you are retaining an instance of yourself. I

Re: Release a NSWindowController after the window is closed

2011-06-19 Thread Roland King
How about adding an instance variable to your window controller subclass which keeps a strong reference to itself. Also register as your own delegate, and nil the strong reference in your windowWillClose: (or perhaps windowDidClose:) Effectively you now have your delegate (yourself) retaining th

Re: Release a NSWindowController after the window is closed

2011-06-19 Thread Marc Respass
Hi Brian, The technique that I have been using for a long time is to alloc/init the window controller, make the window controller the delegate of the window, and invoke [self autorelease] in windowWillClose:. It's essentially the same thing you are doing with less code. The thing that I love a

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Jun 18, 2011, at 12:27 PM, Matt Neuburg wrote: > > On Jun 18, 2011, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote: > >> Date: Sat, 18 Jun 2011 10:09:13 -0700 >> From: Kyle Sluder >> Subject: Re: Release a NSWindowController after the window is closed >

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Evadne Wu
Jun 2011 10:09:13 -0700 >> From: Kyle Sluder >> Subject: Re: Release a NSWindowController after the window is closed > >> This general pattern will fail under ARC (yay, we can talk about that >> now). > > Why are we able to do that? m. > ___

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Greg Guerin
Matt Neuburg wrote: Why are we able to do that? m. Because ARC is public knowledge: http://clang.llvm.org/docs/AutomaticReferenceCounting.html -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or m

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Matt Neuburg
On Jun 18, 2011, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote: > Date: Sat, 18 Jun 2011 10:09:13 -0700 > From: Kyle Sluder > Subject: Re: Release a NSWindowController after the window is closed > This general pattern will fail under ARC (yay, we can talk about that > now

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Sat, Jun 18, 2011 at 10:09 AM, Kyle Sluder wrote: > It's essentially the same delegate/owner pattern you see all over the > place in Cocoa, except the window controller doesn't need a weak > pointer to the app delegate because it cal always get at it by calling > [NSApp delegate]. Actually, I

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Kyle Sluder
On Wed, Jun 15, 2011 at 11:40 AM, Brian Norh wrote: > I'm building a Cocoa application and have a question about using > window controllers. The idea is that when the user selects New from > the File menu, an instance of MyWindowController which is a subclass > of NSWindowController is created and

Re: Release a NSWindowController after the window is closed

2011-06-18 Thread Quincey Morris
On Jun 15, 2011, at 11:40, Brian Norh wrote: > Is there a better way to do this? I have searched the documentation > and have not found anything specific on which practices to use. It > sounds like something very basic which it should cover so maybe I'm > just searching with the wrong terms. I'm