Re: Init Question
Re: Init Question
- Subject: Re: Init Question
- From: Ambroise Confetti <email@hidden>
- Date: Sun, 26 Oct 2003 01:34:58 +0200
Le 26 oct. 03, ` 00:33, Jon Hull a icrit :
What is the proper behavior of an initialization method if it is
passed bad data?
It seems by example (NSArray's initWithContentsOfFile:) that I should
return nil which is fine, but how do I prevent a memory leak, since
alloc has already been called?
If an initializer method returns nil, then it has already released the
object. You don't have to care about releasing it yourself.
(An initializer can also substitute the alloc'ed object with another.
That's why you must absolutely reassign self to the value returned by
the initializer of the superclass in your own initializer.)
Ambroise
http://www.cellulo.info/
_______________________________________________
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.