Rohan Rohan - 3 months ago 8x
Objective-C Question

How to insert object in between the array?

I want to insert an object in between the array.

For Example ;

NSMutableArray *array = [[NSMutableArray alloc]init];
[array addObject:@"1"];
[array addObject:@"3"];
[array addObject:@"4"];
[array addObject:@"5"];

NSLog@"array is - %@", array);

Output will be -

array is - { 1,3,4,5}

But now i want to add another object as "2" in between this array and want the output like this ;

array is - { 1,2,3,4,5}

How can i do this?

I have searched but could not find the solution.

Please help me.


[array insertObject:@"2" atIndex:1];