Objective-C - How to add objects in 2d NSMutableArrays
- by thary
Hello, I have this code
NSMutableArray *insideArray = [[NSMutableArray alloc] init];
NSMutableArray *outsideArray = [[NSMutableArray alloc] init];
[insideArray addObject:@"Hello 1"];
[insideArray addObject:@"Hello 2"];
[outsideArray addObject:insideArray];
[insideArray removeAllObjects];
[insideArray addObject:@"Hello 3"];
[insideArray addObject:@"Hello 4"];
[outsideArray addObject:insideArray];
The current output is
array(
(
"Hello 3",
"Hello 4"
),
(
"Hello 3",
"Hello 4"
)
)
I need a way to get the output to be
array(
(
"Hello 1",
"Hello 2"
),
(
"Hello 3",
"Hello 4"
)
)
Does anyone have a solution or could see where i've gone wrong? Thanks