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
negm-a...@cocoading.de




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 (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:
> http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de
> 
> This email sent to negm-a...@cocoading.de

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to