Here's how you can have an "abstract" class that also initializes non-nil member vars:
// ABC is an abstract class--not to be instantiated directly, but subclassed
@interface ABC : NSObject
@property ( nonatomic ) BOOL isNew ;
@end
@implementation ABC
-(id)init
{
self = [ super init ] ;
if ( [ [ self class ] isEqual:[ ABC class ] ] )
{
@throw [ NSException exceptionWithName:NSGenericException reason:@"Warning: class ABC must be subclassed. Cannot directly create instances of class ABC" userInfo:nil ] ;
return nil ;
}
self.isNew = YES ;
return self ;
}
@end
Your subclass would look like this:
@interface MyConcreteABCSubclass : ABC
@end
@implementation MyConcreteABCSubclass
-(id)init
{
self = [ super init ] ;
if ( self )
{
// initialize subclass vars
}
return self ;
}
//
// ... your subclass methods go here ...
//
@end