Re: When init returns nil does it cause a leak
Re: When init returns nil does it cause a leak
- Subject: Re: When init returns nil does it cause a leak
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 19 May 2009 18:37:49 +0200
Le 19 mai 09 à 18:24, Reza Farhad a écrit :
Hi all
we have an object that gets initialized like most other objects
-(id)init
{
self = [ super init ];
if ( self ){
...do something;
}
return self;
}
if [ super init ] returns nil does this cause a leak, as the memory
has already been created by calling alloc when trying to create the
object
AnObject *object = [[ AnObject alloc ] init ];
I am sure the answer is simple but this suddenly stumbled me.
Thanks
The answer is in the Cocoa Fundamentals Guide > Cocoa Objects > Object
Creation > Implementing Initializer
with a lots of other useful info.
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html
_______________________________________________
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