Create your own initialise function
//**************************************
//**************************************
//********** CLASS INITIALISE **********
//**************************************
//**************************************
//Override the default init in case our class is created using init instead of our initialse funciton (no need to declare in .h file as we're overriding a superclass method)
- (id)init
{
return [self initMyInitFunctionName:@""
Value1:0];
}
//Our new init function:
-(id)initMyInitFunctionName:(NSString *)pName //Always start the name with 'init'
Value1:(int)value1
{
//Call superclass initialiser
self = [super init];
if (!self) //Check it didn't fail
return nil;
//Do init tasks...
//Exit with our address
return self;
}
And create your own dealloc function to release any instance variables
//***********************************
//***********************************
//********** CLASS RELEASE **********
//***********************************
//***********************************
- (void)dealloc
{
[MyObject1 release];
...
[super dealloc]; //Call the super class deallocate once we have released our objects its not aware of
}