// +(Class)class{return self} -(Class)class{return object_getClass(self)}
/*
实例对象
1. -(Class)class; 获取到类对象
2. object_getClass(self); 获取到类对象
3. object_getClass([self class]); 获取元类
类对象
1.+(Class)class; 获取到还是本身
2.object_getClass(self); 获取到元类对象
3.object_getClass([self class]); 获取元类对象
// 为神魔 在一个类里面 [self class] == [super class];
应为oc的方法调用都会是转成消息
[self class] 会调用 objc_msgSend(self,@selecter(class));
[super class] 会调用 objc_msgSendSuper(struct objc_super *super, SEL)
// 这个结构体里面的 receiver 就是self 调用super时他会从父类开始查找class的方法,但是消息的接受者还是 self ,所以打印的它俩相同
struct objc_super {
Specifies an instance of a class.
__unsafe_unretained id receiver;
Specifies the particular superclass of the instance to message.
#if !defined(__cplusplus) && !__OBJC2__
For compatibility with old objc-runtime.h header
__unsafe_unretained Class class;
#else
__unsafe_unretained Class super_class;
#endif
super_class is the first class to search
};
// 发消息,系统会自动从下面几个中间挑选合适的调用
objc_msgSend objc_msgSend_stret objc_msgSendSuper objc_msgSendSuper_stret
* @note When it encounters a method call, the compiler generates a call to one of the
* functions \c objc_msgSend, \c objc_msgSend_stret, \c objc_msgSendSuper, or \c objc_msgSendSuper_stret.
* Messages sent to an object’s superclass (using the \c super keyword) are sent using \c objc_msgSendSuper;
* other messages are sent using \c objc_msgSend. Methods that have data structures as return values
* are sent using \c objc_msgSendSuper_stret and \c objc_msgSend_stret.
*/