【发布时间】:2013-11-13 05:16:04
【问题描述】:
我正在使用 NSOutlineView,我想显示第四个子级别。现在我只能显示三个子级别。
outlineViewController.m
-(id)init{
self = [super init];
if(self){
_people = [[NSMutableArray alloc]init];
Person *quick = [[Person alloc]initWithName:@"First"];
[quick addChild:[[Person alloc]initWithName:@"Second"]];
[(Person *)[quick.children objectAtIndex:0]addChild:[[Person alloc]initWithName:@"Third"]];
[_people addObject:quick];
}
return self;
}
人.m
-(id)init{
return [self initWithName:@"Name"];
}
-(id)initWithName:(NSString *)name {
self = [super init];
if(self){
_name = [name copy];
_children = [[NSMutableArray alloc]init];
}
return self;
}
-(void)addChild:(Person *)p {
[_children addObject:p];
}
人.h
@property (copy)NSString *name;
@property(readonly,copy)NSMutableArray *children;
-(id)initWithName:(NSString *)name;
-(void)addChild:(Person *)p;
我得到的输出是这样的。
>First
>Second
Third
我想要这样的输出..
>First
>Second
>Third
>Fourth
Fifth
谢谢。
【问题讨论】:
-
你正在添加三个孩子,这就是为什么你要获得三个级别,将一个孩子进一步添加到第三个然后到第四个
-
我可以知道如何将孩子添加到孩子吗?
标签: objective-c xcode cocoa nsoutlineview