isMemberOfClass和isKindOfClass区别

if ([scrollView isKindOfClass:[UIView class]]) {
    NSLog(@"scrollView is isKindOfClass UIView");
}

if ([scrollView isKindOfClass:[UIScrollView class]]) {
    NSLog(@"scrollView is isKindOfClass UIScrollView");
}

if ([scrollView isMemberOfClass:[UIView class]]) {
    NSLog(@"scrollView is isMemberOfClass UIView");
}

if ([scrollView isMemberOfClass:[UIScrollView class]]) {
    NSLog(@"scrollView isMemberOfClass UIScrollView");
}

输出结果:
scrollView is isKindOfClass UIView
scrollView is isKindOfClass UIScrollView
scrollView isMemberOfClass UIScrollView

结论:
isMemberOfClass 用于判断(实例对象)和(对象的创建类)
isKindOfClass 用于判断(实例对象)和(对象的创建类或继承的类)

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