我有一个父类,我想在其中使用具有已知超类的类变量。有没有办法告诉编译器超类是什么类型的?
使用外部库我的用例要复杂得多(这就是为什么我必须做这么奇怪的事情。这里简化了:
@interface A
+(void)MagicMethod;
@end
#import "A.h"
@interface B: A
@end
#import "A.h"
@interface C
{
Class class_to_call
}
@implementation C
-(void) fun_method
{
[class_to_call MagicMethod]; // I need some context here to say the base is class A!!!!
}
@end
#import "C.h"
@interface D: C
@end
@implementation D
-(id)init
{
self = [super init];
class_to_call = [B Class];
}
正如您在上面所看到的,没有办法给我用来打电话的班级提供背景信息。是否有语法可以说这个" Class"变量包含一个基类型为A?
的类