nsindexset

How to indicate index of NSIndexSet object?


everyone.

I want to indicate index of NSIndexSet object.

Find various method but I can't find.

How to indicate index of NSIndexSet object?

NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:@"A",@"B",@"C",@"A", nil];

NSIndexSet *indexset = [array indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
    return [obj isEqual:@"A"];
}];

NSLog(@"%@",[array objectsAtIndexes:indexset]);

// I want to indicate index of NSIndexSet object.
NSLog(@"%d",[indexset ?]);

Solution

  • If you want to get number of indices stored in NSIndexSet then use count property:

    NSLog(@"%d",[indexset count]);