很多人对这道面试题的解答就像下面:
1.isMemberOfClass:用于判断一个对象是否属于当前这个类;
2.isKindOfClass:用于判断当前对象是否属于这个类或者这个类的子类;
简直就是以偏概全,胡说七道(因为这种解释不全错)!
apple 自己是这么说的:
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.
在看源码:
https://opensource.apple.com/source/objc4/objc4-532.2/runtime/NSObject.mm
这下你懂了吧