1. [self class] 与 [super class]

猜猜下面的代码的打印结果:

  1. @interface Person : NSObject
  2. @end
  3. @implementation Person
  4. - (instancetype)init {
  5. self = [super init];
  6. if (self) {
  7. NSLog(@"%@-----%@", [self class], [super class]);
  8. }
  9. return self;
  10. }
  11. @end

真实打印结果: LGPerson——-LGPerson
为什么[super class] 的打印结果不是父类 NSObject呢??我们看看 class 的底层实现过程。
1.1

2. 分类与延展的区别

3. 指向类的指针与对象访问对象中的方法与属性