如何获取许多数组中字典中项目的关键路径

时间:2014-01-04 14:54:39

标签: nsarray nsdictionary nsoutlineview

我有一个数组包含字典,字典包含数组等等。

如何在其中一个数组中获取项目的关键路径。

我需要这个将数据库中的层次结构数据(树)呈现给outlineView,所以,我可以通过使用像(parent.children.parent)这样的关键路径来处理我的数组中的第一行但是(子)时的问题有很多项目,其中一个项目有更多项目分机。我该如何看待它的指针?

例如:

_people = [[NSMutableArray alloc]init];
Person *person = [[Person alloc]initWithName:@"parent" age:36];
[person addChild:[[Person alloc] initWithName:@"child1" age:55]];
[person addChild:[[Person alloc] initWithName:@"child2" age:15]];
[person addChild:[[Person alloc] initWithName:@"child3" age:20]];

[(Person*)[person.childrens objectAtIndex:1] addChild:[[Person alloc] initWithName:@"child1 for child2" age:23]];
[(Person*)[[[person.childrens objectAtIndex:1] childrens] objectAtIndex:0]addChild:[[Person alloc] initWithName:@"last child" age:30]];


[_people addObject:person];

现在我如何找到关键值“最后一个孩子”

请帮助!

0 个答案:

没有答案
相关问题