添加NSMutableArray到另一个NSMutableArray中时数组值

  NSMutableArray *no1=[[NSMutableArray alloc]init];
    NSMutableArray *no2=[[NSMutableArray alloc]init];

    for(int i=0;i<3;i++)
    {
        for (int j=0;j<=i;j++)
        {
            NSString *no_str=[NSString stringWithFormat:@"%d",j];
            [no1 addObject:no_str];
        }
        [no2 addObject:no1];
        [no1 removeAllObjects];
    }
    NSLog(@"Final:%@",no2);

实际输出是:

( ( 0, 1, 2 ), ( 0, 1, 2 ), ( 0, 1, 2 ) )

期望输出是:

( ( 0 ), ( 0, 1 ), ( 0, 1, 2 ) )
NSMutableArray *no1;

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

    for(int i=0;i<3;i++)
    {
        no1=[[NSMutableArray alloc]init];
        for (int j=0;j<=i;j++)
        {
            NSString *no_str=[NSString stringWithFormat:@"%d",j];
            [no1 addObject:no_str];
        }
        [no2 addObject:no1];
        [no1 release];
    }
    NSLog(@"Final:%@",no2);

如果你用的ARC,我的代码可以帮忙

NSMutableArray *no1;
NSMutableArray *no2=[[NSMutableArray alloc]init];

for(int i=0;i<3;i++)
{
    no1=[[NSMutableArray alloc]init];
    for (int j=0;j<=i;j++)
    {
        NSString *no_str=[NSString stringWithFormat:@"%d",j];
        [no1 addObject:no_str];
    }
    [no2 addObject:no1];
}
NSLog(@"Final:%@",no2);

在我这里输出结果就是:

( ( 
0
 ), 
(
 0, 
 1 
), 
(
 0, 
 1, 
 2
 ) )