I have a base class that initializes itself from a nib
file.
How can I inherit from this class
.
Every time I init a subclass
of it it creates an object of the base class instead of the actual class
I am trying to create
Base Class
@implementation BaseClass
- (id)init{
self = [[[[NSBundle mainBundle] loadNibNamed:@"BaseClass"
owner:self
options:nil] lastObject] retain];
if (self){
}
return self;
}
@end
A Class
@implementation MyClass //Inheriting from BaseClass
- (void)init {
self = [super init];
if (self) {
}
return self;
}
- (void)methodSpecificToThisClass {
//do something
}
@end
Usage
// 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];