ObjC: using “super” in conjunction with overriding-Collection of common programming errors
I have a class A and a class B which is a subclass of A. Both have the following methods:
-(void)anotherMethod{
// implementation of A or B
}
-(void)aMethod{
@try{
[super aMethod];
}
@catch(NSException *e){
}
[self anotherMethod];
}
Now: if I call [instanceOfClassB aMethod] the instruction [self anotherMethod] contained in A’s implementation of aMethod calls B’s anotherMethod (since it’s overridden) instead of A’s one. How can I make A’s implementation of aMethod call A’s implementation of anotherMethod?