nib
我有一个从文件初始化自身的基类。我怎样才能继承这个class
。每次我初始化subclass
它时,它都会创建一个基类的对象,而不是class
我试图创建的实际对象
基类
@implementation BaseClass
- (id)init{
self = [[[[NSBundle mainBundle] loadNibNamed:@"BaseClass"
owner:self
options:nil] lastObject] retain];
if (self){
}
return self;
}
@end
一类
@implementation MyClass //Inheriting from BaseClass
- (void)init {
self = [super init];
if (self) {
}
return self;
}
- (void)methodSpecificToThisClass {
//do something
}
@end
用法
// It crashes when I call 'methodSpecificToThisClass'
// because the type that has been created is a type
// of my BaseClass instead of MyClass
MyClass *myClass = [[MyClass alloc] init];
[myClass methodSpecificToThisClass];