【iOS】isKindOfClass & isMemberOfClass comparison

When understanding this part of knowledge, you can first refer to the relationship between the following blog
[iOS] class, metaclass, and parent class

Here we draw conclusions directly:

The +isKindOfClass class method starts from the isa point of the current class (that is, the metaclass of the current class), and searches along the superclass inheritance chain to judge and compare whether the classes are equal.

-isKindOfClass The object method starts from [self class] (the current class) and searches along the superclass inheritance chain to judge and compare whether the classes are equal.

The +isMemberOfClass class method is to directly judge whether the isa point of the current class (that is, the metaclass of the current class) is equal to the comparison class.

-isMemberOfClass object method is to directly judge whether [self class] (current class) is equal to the comparison class.

To understand the above text, we also need to use the following picture:
insert image description here

Here is the code we verified:
insert image description here
Compilation results:
insert image description here
Combining the previous blog and the conclusions given, we can easily analyze the reason for outputting 0 or 1

Here I only know how to use these methods. When I learn the source code, I will give supplements to the source code of these methods and the methods called by classes and metaclasses.

Guess you like

Origin blog.csdn.net/weixin_72437555/article/details/130693287