On Apr 5, 2012, at 5:59 AM, Ariel Feinerman wrote:

> the next provocative question is whether can we release self in init before
> raise an exception? I think it has own reason.

Yes, you can release self* in an init method before returning nil or raising an 
exception. 

Although if raising an exception, things are going to be in a weird state 
afterwards anyway, so leaking your object probably isn't significant. For 
example, if you call NSParameterAssert in your init method and it fails, the 
exception will be raised without giving you a chance to release. But if you 
want to call [self release] before @throw, that's fine.

—Jens

* unless you're using ARC or GC, of course.

_______________________________________________

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