cocoaNSIndexSet:多个索引。 如何创build索引集,多个索引?
我想弄清楚如何创build一个让我们说(1,2,3)的索引,然后使用它
- (void)selectRowIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extend  这是(NSIndexSet *)indexes我不知道如何使用/创build/填充索引1,2,3。我应该使用类方法或实例方法吗? 
我尝试了很多方法,但我不知道我在做什么…
如果索引是连续的,就像在你的例子中一样,你可以使用这个:
 NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, 3)]; 
如果不是,则创build一个可变索引集,并逐个添加索引(或范围):
 NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet]; [indexSet addIndex:3]; [indexSet addIndex:5]; [indexSet addIndex:8]; 
 对于包含单个索引或一组索引(可以用范围表示)(1,2,3)的简单索引集,可以使用NSIndexSet的initWithIndex:或initWithIndexesInRange:方法(或其工厂方法对应方法)创build它们。 如果你想创build一个更复杂的索引集(例如1,5,7,8,9),你将需要使用NSMutableIndexSet,以便在创build对象之后添加索引和范围。 
此代码将创build一个包含索引1,2和3的索引集:
 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1,3)]; 
请参阅NSIndexSet和NSMutableIndexSet类的引用。
在Swift 3
 let indexSet = IndexSet(integersIn: 1...3) 
或为一个单一的值:
 let indexSet = IndexSet(integer: 1) 
或者对于非连续值:
 var indexSet = IndexSet() indexSet.insert(1) indexSet.insert(3) indexSet.insert(9) 
下面是一个例子,在NSMutableIndexSet的帮助下从本地数组中删除选定的索引
 NSArray * arrSelectedSongs = [self.playListTblView indexPathsForSelectedRows]; //Delete From Array NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc]init]; for (NSIndexPath *indexPath in arrSelectedSongs) { [indexSet addIndex:indexPath.row]; } [self.arrFiles removeObjectsAtIndexes:indexSet]; 
还有
 [NSIndexSet indexSetWithIndex:1];