I have 1 mutablearray, i want to remove object all indexs but hold object at first index. EXample : Input : Array (a,b,c,d,e) Output: Array (a)
Can you help me. Thanks in advance
NSMutableArray *testArray=[[NSMutableArray alloc] initWithObjects:@"A",@"B",@"C", nil];
[testArray removeObjectsInRange:NSMakeRange(1, testArray.count-1)];
But please make sure array count is greater than 1.
Try this one and put your range to remove your object.
[array removeObjectsInRange:NSMakeRange(1, array.count-1)];
Keep a reference to your a
object (MyObject temp = [array objectAtIndex:0]
), do removeAllObjects
, then insertObject:a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With