Re: self = [super init] debate.
Re: self = [super init] debate.
- Subject: Re: self = [super init] debate.
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 11 Feb 2008 10:27:48 +0100
id newSelf = [super init];
if (self == newSelf) {
...
} else {
[self release];
self = newSelf;
}
return self;
However, that's assuming super always returns either self or an
existing, fully-initialised instance, which as noted previously
doesn't have to be the case...
Generally, protecting against nil should be quite sufficient, as
noted, and in the few cases where a class does do funky voodoo in
its initialisers, it should document as such and explain exactly
what it could hypothetically do, so you can write your subclasses
appropriately.
I disagree with this example. I think, it's the super class
responsability to release self.
The [super init] should be like this:
{
[self release];
return singletonInstance;
}
_______________________________________________
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