On 8 May 2014, at 8:08 am, Mills, Steve <smi...@makemusic.com> 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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to