Re: Returning nil from -init
Re: Returning nil from -init
- Subject: Re: Returning nil from -init
- From: Aram Greenman <email@hidden>
- Date: Wed, 12 Mar 2003 01:58:49 -0800
On Wednesday, March 12, 2003, at 01:18 AM, Chris Ridd wrote:
I've got an init method that can fail if some of the input contains
incorrect data, and I understand the correct approach is to return nil
in
this case. But it isn't clear to me what to do with the partial object
pointed at by self in this case. Is calling dealloc or release
appropriate?
release.
My -dealloc method does a [data release], but I'm concerned that
calling
-dealloc myself is bad style. Can I rely on -release doing the right
thing?
Yes.
The only other change I would make to the code you posted is to just
return nil instead of assigning nil to self and returning self, but
that's mostly style.
Aram
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.