iOS开发中,经常会遇到NSObject比较Class的情况。苹果提供了三种判断的方式:isKindOfClass、isMemberOfClass和isSubclassOfClass,但是这三种方式的使用场景需要区分使用。
一、苹果官方API的解释是:
isKindOfClass:Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.
isMemberOfClass:Returns a Boolean value that indicates whether the receiver is an instance of a given class.
isSubclassOfClass:Returns a Boolean value that indicates whether the receiving class is a subclass of, or identical to, a given class.
二、它们的作用的区别:
isKindOfClass:判断对象是否为某类或者其派生类的实例(对象方法);
isSubclassOfClass:判断对象是否为某类或者