码迷,mamicode.com
首页 > Web开发 > 详细

isa class superclass metaclass

时间:2019-02-15 17:54:28      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:ref   instance   .class   难点   bsp   getc   指针   control   log   

 

 

技术图片

 http://www.cnblogs.com/feng9exe/p/7232915.html

 

Note: 其实这里的难点就在于对 和 的区分。

  • .class 当 target 是 Instance 则返回 Class,当 target 是 Class 则返回自身
  • object_getClass 返回 指针的指向 

 

ViewController: 0x10deee650, ViewController, 0

ViewController: 0x10deee678, NSObject, 1

NSObject: 0x10ef8cee8, NSObject, 1

NSObject: 0x10ef8cee8, NSObject, 1

 

ViewController

UIViewController

UIResponder

NSObject

 

ViewController: 0x10deee650, ViewController, 0

ViewController: 0x10deee650, ViewController, 0

 

 

   Class currentClass = object_getClass(self);

    Class nextClass = object_getClass(currentClass);

    Class superClass = class_getSuperclass(currentClass);

    Class xClass = self.class;

 

    int k = 0;

    do {

        NSLog(@"%@:\t%p,\t%s,\t%zd",NSStringFromClass(currentClass),currentClass,object_getClassName(currentClass),class_isMetaClass(currentClass));

        currentClass = nextClass;

        nextClass = object_getClass(currentClass);

    }while (k++ < 4);

    

    NSLog(NSStringFromClass(self.class));

    while (superClass != NULL) {

        NSLog(NSStringFromClass(superClass));

        superClass = class_getSuperclass(superClass);

    }

    

    k = 0;

    do {

        NSLog(@"%@:\t%p,\t%s,\t%zd",NSStringFromClass(xClass),xClass,object_getClassName(xClass),class_isMetaClass(xClass));

        xClass = xClass.class;

        //nextClass = object_getClass(currentClass);

    }while (k++ < 3);

 

isa class superclass metaclass

标签:ref   instance   .class   难点   bsp   getc   指针   control   log   

原文地址:https://www.cnblogs.com/feng9exe/p/10384535.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!