0
的NSArray遞歸搜索我試圖通過索引索引
這裏我的代碼找到數組項。
- (NSDictionary *) getItemAtIntex:(int) index inArray:(NSArray *) array
{
for (NSDictionary *item in array)
{
if (enumerateIndex == index)
{
NSLog(@"%@",item[@"comment"]);
return item;
}
else if ([item[@"childs"] count])
{
enumerateIndex ++;
[self getItemAtIntex:index inArray:item[@"childs"]];
}
}
return nil;
}
我打電話給我的方法
enumerateIndex = 0;
NSDictionary *comment = [self getItemAtIntex:indexPath.row inArray:comments];
例如,索引1,在調試我有兩個答案
subGL 1 -> 1
global 2
我需要在響應僅subGL 1 -> 1
這裏我文件https://www.dropbox.com/s/mvc21a8pl5n6xz3/commenst.json