isMemberOfClass和isKindOfClass区别
2019-06-22 本文已影响0人
coding_Liu
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 用于判断(实例对象)和(对象的创建类或继承的类)