Re: Properly writing an Init method
Re: Properly writing an Init method
- Subject: Re: Properly writing an Init method
- From: jerome LAURENS <email@hidden>
- Date: Thu, 18 Jul 2002 13:26:38 +0200
Le jeudi 18 juillet 2002, ` 06:35 AM, Julian Barkway a icrit :
Fair point. So what are the benefits of assigning to self in this way,
rather than using, say,
if (![super init])
return nil;
// Init stuff...
return self;
I'm only asking because I recently had a problem which was caused by an
object being typed to it's own superclass, rather than the class it
should have been typed to, and it struck me this could have been caused
by my use of 'self = [super init]'...
while not using assignment 'self = [super init...]', there might be a
problem if super returns anything else than itself. It may occur when
one creates a subclass of a singleton or instances of classes that use
opaque types. However, this seems to be rare. But this allows further
modifications of super implementation orthogonal to the implementation
of self.
_______________________________________________
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.