子类同过isKindOfClass判断是否是父类的类型时,是会返回YES的

比如:

NSMutableArray *arr01 = [[NSMutableArray alloc] initWithCapacity:1];
if ([arr01 isKindOfClass:[NSArray class]]) {
    NSLog(@"NSMutableArray is kind of class NSArray");
}
else {
    NSLog(@"NSMutableArray is NOT kind of class NSArray");
}

能够打印:

NSMutableArray is kind of class NSArray

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2021-11-13
  • 2021-12-06
  • 2021-11-29
  • 2021-10-19
猜你喜欢
  • 2022-01-01
  • 2022-01-04
  • 2022-01-04
  • 2022-12-23
  • 2021-12-09
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案