rendered paste body//
// TextNode.m
// Nodes1
//
// Created by User1 on 5/12/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "TextNode.h"
@implementation TextNode
@synthesize name, text, parents, children;
- (id)initWithName:(NSString *)newName {
if ((self = [super init])) {
name = [newName retain];
}
return self;
}
- (id)initWithChildrenAndName:(NSString *)newName {
if ((self = [super init])) {
name = [newName retain];
TextNode *one = [[TextNode alloc] initWithName:@"one"];
TextNode *two = [[TextNode alloc] initWithName:@"two"];
[self addChild:one];
[self addChild:two];
}
return self;
}
- (void) addChild: (TextNode *) child
{
[children addObject:child];
}
- (NSInteger) countChildren
{
return [children count];
}
- (TextNode *) childAt: (NSInteger) index
{
return [children objectAtIndex:index];
}
- (BOOL) hasChildren
{
return (0 != [children count]) ? YES : NO;
}
@end