I wonder whether it's possible to access a method declared in a parent class, which has been overrided (Sorry for my English if I make any mistakes). The code snippet:
#import <stdio.h>
#import <objc/Object.h>
@interface Parent : Object
-(void) message;
@end
@implementation Parent
-(void) message
{
printf("\nParent\n");
}
@end
@interface Child : Parent
//-(void) message;
@end
@implementation Child
-(void) message
{
printf("\nChild\n");
}
@end
int main(int argc, const char* argv[])
{
Parent* p = [[Child alloc] init];
[p message];
[p free];
return 0;
}
So my question is, how can I call the 'message' method defined in the parent class, when the Parent* pointer points to a Child object. Objective-C (being a pure dynamic language) automatically calls the Child's method, but is it possible to call the method of the parent class from outside, through the *p pointer? I mean, when I send the message 'message' to 'p', not "Child" but "Parent" would be shown on the screen.
Thank you.