super 指传入的self 指当前对象
例子 新建一个父类、一个子类 Person SubPerson
在子类中打印
#import "SubPerson.h" @implementation SubPerson -(void)test{ NSLog(@"%@",[self class]); // SubPerson NSLog(@"%@",[self superclass]); // Person NSLog(@"%@",[super class]); // SubPerson NSLog(@"%@",[super superclass]); //Person }
在子类中调用 在父类中打印
#import "SubPerson.h" @implementation SubPerson -(void)test{ [super test]; } @end #import "Person.h" @implementation Person -(void)test{ NSLog(@"%@",[self class]); // SubPerson NSLog(@"%@",[self superclass]); // Person NSLog(@"%@",[super class]); // SubPerson NSLog(@"%@",[super superclass]); //Person } @end