isa pointer in objective-c

前端 未结 4 1868
感动是毒
感动是毒 2021-02-02 14:20

From this reference:

When a new object is created, memory for it is allocated, and its instance variables are initialized. First among the object’s vari

4条回答
  •  借酒劲吻你
    2021-02-02 14:41

    isa points to the class object so this would work

    if(self->isa == [self class])
        NSLog(@"True");
    

    Understanding how to use this, would have some benefits, such as introspection and tests on the class objects of the created object

提交回复
热议问题