I stumbled upon this post In Objective-C why should I check if self = [super init] is not nil?
I can understand this syntax:
- (id)initWithString:(NSString *)aString
{
self = [super init];
if (self)
{
instanceString = [aString retain];
}
return self;
}
or this syntax:
- (id)init;
{
if (!(self = [super init]))
return nil;
// other stuff
return self;
}
but I still don't understand the "standard" template syntax
- init {
if((self = [super init])) {
// set up instance variables and whatever else here
}
return self;
}
Can someone tell as clearly as possible what (3) does more or less compared to (1) or (2) ? All I read is so confusing (why people can't agree with something which is purely technical seems like politics :))
Nevertheless as I read authors article, and as I can fuzzily understand it goes far beyond just syntactic sugar debate or matter of taste. For example it is said:
Curiously then, while case 3 is overwhelmingly more common, initializers that support 1, 2 and 4 but are incompatible with case 3 have become the standard.Curiously then, while case 3 is overwhelmingly more common, initializers that support 1, 2 and 4 but are incompatible with case 3 have become the standard.
So I'd like to have a deep philosophical answer from Objective C Gurus if possible.