下标索引NSIndexSet

       在操作数组或者字典的时候,有时候需要数组中的元素挑选出几个,然后组成新的数组,这时候使用NSIndexSet会非常的方便。       

 NSArray *arr = @[@"look",@"that",@"country",@"very",@"nice"];
        NSIndexSet *_set = [[NSIndexSet alloc]initWithIndexesInRange:NSMakeRange(2, 3)];//使用NSRange来设置需要的元素范围
        NSArray *arr2 = [arr objectsAtIndexes:_set];
        NSLog(@"%@",arr2);
        
        NSMutableIndexSet *_muset = [[NSMutableIndexSet alloc]init];//设置可变下标来添加下标值
        [_muset addIndex:0];
        [_muset addIndex:2];
        [_muset addIndex:4];
        NSArray *arr3 = [arr objectsAtIndexes:_muset];
        NSLog(@"%@",arr3);
原文地址:https://www.cnblogs.com/moxuexiaotong/p/4967634.html