Re: Document being reopened on launch during modal dialog
Re: Document being reopened on launch during modal dialog
- Subject: Re: Document being reopened on launch during modal dialog
- From: Graham Cox <email@hidden>
- Date: Thu, 08 May 2014 10:08:45 +1000
On 8 May 2014, at 8:08 am, Mills, Steve <email@hidden> wrote:
> Is this all safe and legal, releasing self right before it returns to whatever called it?
I believe so, I've done this rarely but occasionally, and it's OK, though if you forget you've done this and later change the calling behaviour in such a way that you assume the object is still there on return from -runDlog it will crash.
If you want to be safer, you could use -autorelease instead, which will allow it to live a little longer, until the call stack to this point has unwound and returned to the main loop.
There are probably also better ways to set this up in general, such that the runner object is automatically disposed when it's done its job - for example using a block? I've just woken up, so off the top of my head I'm not ready to pinpoint the best approach.
--Graham
_______________________________________________
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