Is there a way to call the init
method of a superclass that is not the immediate parent class? I'm trying to setup three classes each of which is a subclass of the previsous (ClassA : ClassB : ClassC
). I've set this up this way because I want each class to be able to call the methods of it's parent (or grand-parent). I would like to override the init
method for each class, so that each calls the base NSObect method init
and then set's values for various instance variables of each class. The problem I'm running into is that the statement:
self = [super init]
only works at the highest level of recurision. Each of the two levels of subclasses try to call the init method of their immediate parent and choke on the instance variables that aren't applicable to them. Is this the wrong way to setup the relationships of these classes? I think that in all three cases, if I didn't want to call the methods of the second class from within the methods of the first I would not subclass them to each other, but just make them all subclasses of NSObject. Have I gone about this the wrong way?