Quote:
Originally Posted by neduhamel
Hi Smasher !
Thanks a lot for your reply.
the "initWithParent" sound like a good idea, but my problem is that i don't know technically how to define the parent class as a member of the child class.
|
How did you define the child class as a member of the parent class? You need the same thing - an instance variable and possibly a property.
This is how you'd define the initWithParent method. It will look funny if you've never written an init method before.
Code:
-(void) initWithParent: (id) parent
{
self=[super init];
if (self){
my_parent=parent;
}
return self;
}
Note that I used "super" here because I need to call the init method of the class that B inherits from (B's superclass; probably NSObject?)