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?