我有 2 个类,Parent 和 Child,Parent 有一个名为 func 的类方法。现在我想在 func 方法中获取 Class 实例来区分哪个类是调用者。
@interface Parent : NSObject
+ (void)func;
@end
@implementation Parent
+ (void)func {
Class *class = howToGetClass();
NSLog(@"%@ call func", class);
}
@end
@interface Child : Parent
@end
int main() {
[Child func]; // call func from Child
}
有没有办法在类方法中获取类实例(或类名)?