I am subclassing NSObject
@interface MyClass : NSObject {
}
-(id)customInit;
@end
and implementing a custom init method in it,
-(id)customInit
{
self = [super init];
if(self)
{
return self;
}
return nil;
}
and creating an instance of MyClass as below
MyClass *myClassInstance = [[MyClass alloc]customInit];
Now my question is, what will I miss if I use an customInit method without self = [super init]; like below,
-(id)customInit
{
return self;
}
Will I miss anything from the NSObject class which is the super class? Thanks
If I don’t [super init] in my customInit method, I will be missing the work done by the init method of NSObject. But otherwise I will have access to all the methods of super class and its protocols as I am inheriting it.