search

Home  >  Q&A  >  body text

objective-c - +load方法里面 self 和 [self class] 返回的对象是同一个

cls和selfcls 指向同一个地址(RuntimeViewController类对象)。

按照oc的类结构,[self class]不是应该指向RuntimeViewController的元类吗?

某草草某草草2757 days ago660

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-02 09:28:54

    Look at this and you will understand
    http://xiongzenghuidegithub.github.io/blog/2016/05/17/runtime-part7-object-getclass-yu-object-class-de-qu-bie/

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-02 09:28:54

    
    
        //实例对象调用class时返回isa指向的objc_object
        -class
        {
            return (id)isa; 
        }
        
        //类对象调用class时返回类对象自己
        +class 
        {
            return self;
        }
        
        
        //取自Object.h Object.m

    reply
    0
  • Cancelreply