NSMutableArray removeObjectAtIndex
- (void)removeObjectAtIndex:(NSUInteger)index
Parameters
index
The index from which to remove the object in the array. The value must not exceed the bounds of the array.
Important: Raises an NSRangeException if index is beyond the end of the array.
Discussion of [NSMutableArray removeObjectAtIndex]
To fill the gap, all elements beyond index are moved by subtracting 1 from their index.
NSMutableArray removeObjectAtIndex example.
NSMutableArray *mArray = [[NSMutableArray alloc]init];
[mArray addObject:@"one"];
[mArray addObject:@"two"];
[mArray addObject:@"three"];
[mArray removeObjectAtIndex:0];
NSLog(@"mArray at 0: %@",[mArray objectAtIndex:0]);
[mArray addObject:@"one"];
[mArray addObject:@"two"];
[mArray addObject:@"three"];
[mArray removeObjectAtIndex:0];
NSLog(@"mArray at 0: %@",[mArray objectAtIndex:0]);
Example of [NSMutableArray removeObjectAtIndex].
if (indexPath.row>=0 && indexPath.row
[bookmarkCollection removeObjectAtIndex: indexPath.row];
} else {
NSLog(@"indexPath.row is out of boundry of bookmarkCellection size: %d", bookmarkCollection.count);
}
} else {
NSLog(@"indexPath.row is out of boundry of bookmarkCellection size: %d", bookmarkCollection.count);
}
NSMutableArray removeObjectAtIndex example.
NSMutableArray *sampleArray = [[NSMutableArray alloc]
initWithObjects:@"1",@"2",@"3",@"4", nil];
NSLog(@"%@", sampleArray);
[sampleArray removeObjectAtIndex:0];
NSLog(@"%@", sampleArray);
initWithObjects:@"1",@"2",@"3",@"4", nil];
NSLog(@"%@", sampleArray);
[sampleArray removeObjectAtIndex:0];
NSLog(@"%@", sampleArray);