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);
I got output like:
Final:(
(
0,
1,
2
),
(
0,
1,
2
),
(
0,
1,
2
)
)
But i need output like this:
Final:(
(
0
),
(
0,
1
),
(
0,
1,
2
)
)
Please any one help me.
I assume you are using ARC, so this code will work good.
EDIT: even if you alloc init the no1 the result will be same.