• 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: retaining and releasing a Window Controller.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retaining and releasing a Window Controller.


  • Subject: Re: retaining and releasing a Window Controller.
  • From: Negm-Awad Amin <email@hidden>
  • Date: Mon, 9 Aug 2010 09:12:07 +0200

That one, who creates the WC is the owner (probably the App-Delegate or a document). It should retain the WC. The WC can send a message to the owner, when its window is closed. (And the owner probably wants to autorelease the WC in this case.)

Problem: When the WC is released by its owner after sending a message to its owner, the code execution returns to a probably deallocated instance. For that reason you should autorelease the WC instead of releasing it or dispatch the release through the run loop.

Cheers

Amin Negm-Awad
email@hidden




Am Mo.,09.08.2010 um 08:27 schrieb Kevin Bracey:

> Hi guys,
>
> every time I find myself doing something convoluted I think hey I must be doing this wrong:-)
>
> I have a Report WindowController, that opens a Window from it's own nib. This is great, I can open lots of different Reports all bases on the same Controller. But I only need the Window and the controller to stay around while the Window is open. It's all self contained and nothing else needs reference it.
>
> Is it ok to [self retain] in the Controller's init, then [self release] in the - (void)windowWillClose:(NSNotification *)notification. Is that the best place to do this, I'm not at all sure about an object retaining and releasing itself.
>
> at the moment I'm storing all these reports in an array to stop the controller disappearing out from underneath me and then removing them when the Window closes, I'm sure there's a better way.
>
> Cheers
> Kevin_______________________________________________
>
> 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

_______________________________________________

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

References: 
 >retaining and releasing a Window Controller. (From: Kevin Bracey <email@hidden>)

  • Prev by Date: retaining and releasing a Window Controller.
  • Next by Date: Re: retaining and releasing a Window Controller.
  • Previous by thread: retaining and releasing a Window Controller.
  • Next by thread: Re: retaining and releasing a Window Controller.
  • Index(es):
    • Date
    • Thread