Objective c 如何在NSMutableArray中存储和检索数组

Objective c 如何在NSMutableArray中存储和检索数组,objective-c,ios,nsmutablearray,Objective C,Ios,Nsmutablearray,朋友们好,我想在NSMutableAray中存储NSMutableAray,并想检索它。我可以存储它,但无法访问它。我的代码如下: NSMutableArray *muteArray; NSMutableArray *muteArray_Master; NSMutableArray *mutArrar_Level1; NSArray *Children = [dictionary objectForKey:@"Children"]; if (Children.cou

朋友们好,我想在NSMutableAray中存储NSMutableAray,并想检索它。我可以存储它,但无法访问它。我的代码如下:

NSMutableArray *muteArray;
NSMutableArray *muteArray_Master;
NSMutableArray *mutArrar_Level1;            


NSArray *Children = [dictionary objectForKey:@"Children"];

if (Children.count > 0) {
    muteArray = [NSMutableArray arrayWithArray:Children];
}

muteArray_Master= [[NSMutableArray alloc] init];
mutArrar_Level1= [[NSMutableArray alloc] init];



[muteArray_Master addObject:muteArray]; // muteArray_Master array added one object successfully 

i = [muteArray_Master count]; // Here I have i=1

mutArrar_Level1 = [NSMutableArray arrayWithArray:[muteArray_Master objectAtIndex:i-1]]; // But here mutArrar_Level1 not producing correct data.still it is with 0 objects  
所以我的要求是在NSMutableArray中存储多个NSMutableArray,并在另一个中访问所有NSMutableArray

谢谢
Deepak R

首先,我恐怕要告诉您需要处理变量名。看

无论如何,以下是如何将多个数组添加到一个数组中:

NSMutableArray *parentArray = [[NSMutableArray alloc] init];

for (int i = 0; i < 10; i++) {
    NSArray *childArray = [NSArray arrayWithObjects:
        [NSString stringWithFormat:@"a-%i", i], 
        [NSString stringWithFormat:@"b-%i", i], 
        [NSString stringWithFormat:@"c-%i", i],
        nil];

    [parentArray addObject:childArray];
}
这是您再次访问所有这些文件的方式:

for (int i = 0; i < 10; i++) {
    NSArray *childArray = [parentArray objectAtIndex:i];
    NSLog(@"Child Array %i", i);

    for (NSString *item in childArray) {
        NSLog(@"  Item: %@", item);
    }
}

非常简单:

首先,我恐怕要告诉您需要处理变量名。看

无论如何,以下是如何将多个数组添加到一个数组中:

NSMutableArray *parentArray = [[NSMutableArray alloc] init];

for (int i = 0; i < 10; i++) {
    NSArray *childArray = [NSArray arrayWithObjects:
        [NSString stringWithFormat:@"a-%i", i], 
        [NSString stringWithFormat:@"b-%i", i], 
        [NSString stringWithFormat:@"c-%i", i],
        nil];

    [parentArray addObject:childArray];
}
这是您再次访问所有这些文件的方式:

for (int i = 0; i < 10; i++) {
    NSArray *childArray = [parentArray objectAtIndex:i];
    NSLog(@"Child Array %i", i);

    for (NSString *item in childArray) {
        NSLog(@"  Item: %@", item);
    }
}

非常简单:

谢谢你,伙计,很抱歉我的变量命名。没问题。如果你坚持命名约定,你会帮你自己和你团队中的其他人一个忙。另外,请不要忘记向上投票并接受答案。谢谢老兄,很抱歉我的变量命名。没问题。如果你坚持命名约定,你会帮你自己和你团队中的其他人一个忙。另外,请不要忘记投票并接受答案。