oc基础

iOS的super

2018-09-21  本文已影响3人  GeniusWong

isKindOfClass

isMemberClass

@implementation Teacher

-(id)init
{
      self = [super init];
      if (self) {
        [self class];//  Teacher
        [self superclass]; // NSObject
// 这两块,打印输出是一样的?
        [super class];  // Teacher
        [super superclass];//  NSobject
        // objc_msgSuper( { self, 父类 } ,  selector()) ;
      }
}

@end
struct objc_super {
    /// Specifies an instance of a class.
    __unsafe_unretained _Nonnull 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 _Nonnull Class class;
#else
    __unsafe_unretained _Nonnull Class super_class;
#endif
    /* super_class is the first class to search */
};
上一篇 下一篇

猜你喜欢

热点阅读