Q:

cocoa: how to implement a link in objective-c

I have a Person class which has an instance variable: Name and Person. 
@interface Person : NSObject{
    NSString *name;
    Person *child;
}

@property (copy) NSString *name;
@property (strong) Person *child;
@end

@implementation Person
@synthesize name;
@synthesize child;

-(id) init{
    self = [super init];
    if(self){
        name = @"";
        child = [[Person alloc]init];
    }
    return self;
}
@end

If I create a Person object, like: 
Person *parent = [[Person alloc]init]; 

the program will repeat to create Person instances, how can I solve this?

A:

Not all persons have children, so why are you allocating a child each time a new person is created?
In other words, don't do what you're doing. If a person does happen to have a child, create that child separately and set the person's child property appropriately.

