Re: exception in init
Re: exception in init
- Subject: Re: exception in init
- From: Jens Alfke <email@hidden>
- Date: Thu, 05 Apr 2012 08:58:53 -0700
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 (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