class:获取方法调用类名
superclass:获取方法调用者的父类类名
super:编译修饰符,不是指针,指向父类标志,
本质还是拿到当前对象去调用父类的方法
注意:super并不是拿到父类对象去调用父类方法
1 #import <Foundation/Foundation.h> 2 @interface Person : NSObject 3 - (void)test; 4 @end 5 6 #import "Person.h" 7 @implementation Person 8 - (void)test 9 { 10 // self:SonPerson 11 // 输出结果 SonPerson Person self:SonPerson 12 NSLog(@"%@ %@ %@",[self class],[self superclass],[super class]); 13 } 14 @end 15 16 #import "Person.h" 17 18 @interface SonPerson : Person 19 @end 20 21 #import "SonPerson.h" 22 23 @implementation SonPerson 24 - (void)test 25 { 26 // 输出结果:SonPerson Person SonPerson 27 // NSLog(@"%@ %@ %@",[self class],[self superclass],[super class]); 28 [super test]; 29 } 30 31 #import "ViewController.h" 32 33 #import "SonPerson.h" 34 35 @interface ViewController () 36 37 @end 38 39 40 #import <UIKit/UIKit.h> 41 @interface ViewController : UIViewController 42 @end 43 44 @implementation ViewController 45 - (void)viewDidLoad { 46 [super viewDidLoad]; 47 SonPerson *son = [[SonPerson alloc] init]; 48 [son test]; 49 } 50 @end
输出结果:SonPerson Person SonPerson