在Objective-C中,我希望有一个子类调用或调用父类的方法。正如在父母已经分配了孩子,孩子做了一些会调用父母方法的东西。像这样:子类调用父类的方法
//in the parent class
childObject *newChild = [[childClass alloc] init];
[newChild doStuff];
//in the child class
-(void)doStuff {
if (something happened) {
[parent respond];
}
}
我怎么能这样做呢? (如果你能解释清楚,我将不胜感激)
的可能的复制[HOWTO访问在父类中声明的方法是什么?] (http://stackoverflow.com/questions/5063484/howto-access-the-method-declared-in-the-parent-class) – moonman239 2016-11-29 01:31:02