Why in Objective-C, we use self = [super init] instead of just [super init]?
- by ????
In a book, I saw that if a subclass is overriding a superclass's method, we may have
self = [super init];
First, is this supposed to be done in the subclass's init method?
Second, I wonder why the call is not just
[super init];
? I mean, at the time of calling init, the memory is allocated by alloc already (I think by [Foobar alloc] where Foobar is the subclass's name. So can't we just call [super init] to initialize the member variables? Why do we have to get the return value of init and assign to self? I mean, before calling [super init], self should be pointing to a valid memory allocation chuck... so why assigning something to self again?
(if assigning, won't [super init] just return self's existing value?)