isKindOfClass、isMemberOfClass、isSubclassOfClass的区别

1.isKindOfClass
[subClassObj isKindOfClass:superClass]; 返回YES
[subClassObj isKindOfClass:subClass]; 返回YES

2.isMemberOfClass
[subClassObj isKindOfClass:superClass]; 返回NO
[subClassObj isKindOfClass:subClass]; 返回YES

总之:1与2都是实例方法,2比1更为严格

3.isSubclassOfClass是类方法
[subClass isSubclassOfClass:superClass]; 返回YES
[subClass isSubclassOfClass:subClass]; 返回YES

你可能感兴趣的:(isKindOfClass、isMemberOfClass、isSubclassOfClass的区别)