• 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: NSWindowController retain count confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController retain count confusion


  • Subject: Re: NSWindowController retain count confusion
  • From: Patrick Mau <email@hidden>
  • Date: Wed, 1 Oct 2008 02:49:24 +0200

On 30.09.2008, at 04:30, James Walker wrote:

I have an NSWindowController subclass that is defined as File's Owner in a nib. The window outlet is connected to a window, and the delegate outlet of the window goes back to the File's Owner. I was trying to release the controller in the windowWillClose: delegate method, but it didn't cause the dealloc method to be called. I found that immediately after creating the controller with alloc and init, its retain count was 1, but as soon as I did [self window], the retain count went up to 2. So, who's retaining the controller, and is it safe to just release it twice?

I searched the list, and found some old messages about NSWindowController retain counts being messed up by bindings, but I don't have any bindings (yet).
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>

Hallo Jamws

I've just started Cocoa Programming a few month back, so I'm no expert.
The documentation for "(void)setReleasedWhenClosed: (BOOL)releasedWhenClosed" states:


"YES to specify that the receiver is to be hidden and released when it receives a close message; NO to specify that the receiver is only hidden, not released."

"Another strategy for releasing an NSWindow object is to have its delegate autorelease it on receiving a windowShouldClose: message."

I'd try the second approach because you can control the behaviour at close time.

Regards,
Patrick



_______________________________________________

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


  • Prev by Date: Re: Play Playlist in iTunes
  • Next by Date: Can we discuss iPhone development yet?
  • Previous by thread: Re: Collections can be simple Attributes in Core Data
  • Next by thread: Re: NSWindowController retain count confusion
  • Index(es):
    • Date
    • Thread