1、前置条件:Student 继承 Person
Person *p = [[Person alloc]init];
Student *s= [[Student alloc]init];
2、差别:
类的实例与类比较;都是 YES
[p isKindOfClass:[Person class]]
[p isMemberOfClass:[Person class]
类的实例与父类比较:
[s isKindOfClass:[Person class]] 返回 YES
[s isMemberOfClass:[Person class] 返回 NO
总结:
isKindOfClass :类的实例与当前类、父类都相等
isMemberOfClass:类的实例与当前类的实例相等,与父类不等
网友评论