iOS isKindOfClass判断

子类同过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

 

posted @ 2018-02-02 10:53  子柱  阅读(824)  评论(0编辑  收藏  举报