可以通过 isKindOfClass 判断对象的类型
1 @interface A : NSObject 2 3 @end 4 @implementation A 5 6 @end 7 //// 8 @interface AA : A 9 10 @end 11 @implementation AA 12 13 @end 14 //// 15 @interface B : NSObject 16 17 @end 18 @implementation B 19 20 @end 21 int main(int argc, char * argv[]) { 22 A *a = [[A alloc]init ]; 23 // 运行结果1 24 NSLog(@"%d",[a isKindOfClass:[NSObject class]]); 25 26 @autoreleasepool { 27 return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 28 } 29 }