NSArray has useful methods to find objects for specified indexes
// To find objects by indexes
- (id)objectAtIndex:(NSUInteger)index
- (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes
// To find index by object
- (NSUInteger)indexOfObject:(id)anObject
However, I want to get NSIndexSet (multiple indexes) for given objects. Something ...
I'm trying to delete a section from a UITableView using animation and custom table section header UIViews.
I use...
//Deletion from my model done here (not shown) and then perform the deleteSections...
[self.tableView beginUpdates];
[self.tableView
deleteSections:[NSIndexSet indexSetWithIndex:index]
withRowAnimation:UITableViewRow...
I'm getting the select items from a table view with:
NSIndexSet *selectedItems = [aTableView selectedRowIndexes];
what's the best way to get the indexes in a NSArray object?
...
I want to select some objects from an array. Therefore I'm using begin and end indexes of my selection.
NSLog(@"start:%d\nend:%d", startIndex, endIndex);
NSIndexSet *myIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(startIndex, endIndex)];
NSLog(@"%d", [myIndexes lastIndex]);
The first NSLog gives me
startIndex:49
...