In ObjectiveC, recommended idiom of an init method is :
- (id)init {
if (self = [super init]) {
myInstanceVariable = someConstant;
}
return self;
}
This is because, superClass's init might return a different object than the current object, freeing the current object using [self release];
If that happens :
1) After the call to [super init] finishes, won't control return to original object's init method ?
2) And, won't the next line set myInstanceVariable of the original object ( on which, super-class called release) ?
And if this is the case, would changing the line to :
self->myInstanceVariable = someConstant;
help (so that, myInstanceVariable of the object returned by [super init] is set, instead of the original object) ?