So is this method correct or not ?
- (id) init
{
self = [super init] ;
if ( self == nil ) return nil ;
return self ;
}
From a syntical point of view its correct. But to me as an ex-Smalltalk programmer, its bogus (even from a conceptual view).
Because, think of it, why would you change yourself with something that's returned from initialization of an object of the superclass ?
Self is at the moment of initialization an instance of the whole classtree of the class you instantiate.
You can even introduce (unwanted) side effects with this construction.
No comments:
Post a Comment