Joanna,
You're right. On 08/05/2010, at 11:06, Joanna Carter wrote: > BTW, you should not declare id* as the return type, it should be simply id. > > - (id) init > { > if (self = [super init]) > { > // rest of initialisation > } > > return self; > } I made lots of mistakes in my example code. I meant to write exactly what you wrote above, except for: if (self = [super init]) which I would replace with: if ([super init] != nil) Let's say I create a subclass of NSObject (let's call it "MyOddObject") and override its -init method: - (id)init { self = [super init]; // blah blah blah ... return self; // return type will be NSObject!! } And then I instantiate this class afterwards: MyOddObject* myOddInstance = [[MyOddObject alloc] init]; I should get an instance of MyOddObject, but I am getting a NSObject instead. All right, I think the above line also casts the return value to MyOddObject. Am I right? My question is: apart from the optimization advantages cited by James Bucanek, why would one set self's value to the return value of [super init]? Wouldn't it be confusing? Cheers, Flavio_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com