Error:

Create empty index set

NSIndexSet *set = [NSIndexSet indexSet];

Create index set with one index

NSIndexSet *set = [NSIndexSet indexSetWithIndex:1];

Create index set with indexes in range

NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 99)];

Check whether the index set contains given index

BOOL present = [set containsIndex:99];

Check whether the index set contains all the indexes in another set

BOOL present = [set containsIndexes:anotherSet];

Check whether the index set contains all the indexes represented by an index range

BOOL present = [set containsIndexesInRange:NSMakeRange(0, 10)];

Check whether the index set contains any of the indexes in a range

BOOL intersects = [set intersectsIndexesInRange:NSMakeRange(0, 10)];

Get the number of indexes in the index set

NSUInteger total = [set count];

Get the number of indexes in the index set that are members of a given range

NSUInteger total = [set countOfIndexesInRange:NSMakeRange(0, 10)];

Get the first index of the object that passes predicate Block test

NSUInteger firstOddIndex = [set indexPassingTest:^(NSUInteger idx, BOOL *stop) {
    if (idx % 2)
        return YES;
    else
        return NO;
}];

Get all indexes that pass predicate Block test

NSIndexSet *oddIndexes = [set indexesPassingTest:^(NSUInteger idx, BOOL *stop) {
    if (idx % 2)
        return YES;
    else
        return NO;
}];

Get the index of the first object in the specified range that passes the predicate Block test

NSUInteger firstOddIndexIn20to30 = [set indexInRange:NSMakeRange(20, 10) options:0 passingTest:^(NSUInteger idx, BOOL *stop) {
    if (idx % 2)
        return YES;
    else
        return NO;
}];

Get all indexes in the specified range that passes the predicate Block test

NSIndexSet *oddIndexes20to30 = [set indexesInRange:NSMakeRange(20, 10) options:0 passingTest:^(NSUInteger idx, BOOL *stop) {
    if (idx % 2)
        return YES;
    else
        return NO;
}];

Enumerate over the ranges in the index set using block

[set enumerateRangesInRange:NSMakeRange(0, 10) options:0 usingBlock:^(NSRange range, BOOL *stop) {
    // do something useful
}];

Enumerate over the ranges of the index set in the range of objects using the block

[set enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
    // do something useful
}];

Check if two index sets are equal

BOOL equal = [set isEqualToIndexSet:anotherSet];

Get the first index in the set

NSUInteger idx = [set firstIndex];

Get the last index in the set

NSUInteger idx = [set lastIndex];

Get the closest index in the index set that is less than a specific index

NSUInteger idx = [set indexLessThanIndex:10];

Get the closest index that is less than or equal to a specific index

NSUInteger idx = [set indexLessThanOrEqualToIndex:10];

Get the closest index in the index set that is greater than a specific index

NSUInteger idx = [set indexGreaterThanIndex:10];

Get the closest index that is greater than or equal to a specific index

NSUInteger idx = [set indexGreaterThanOrEqualToIndex:10];

Enumerate over the indexes in the index set using block

[set enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
    // do something useful
}];

Enumerate over the indexes of the index set in given range using the block

[set enumerateIndexesInRange:NSMakeRange(0, 10) options:0 usingBlock:^(NSUInteger idx, BOOL *stop) {
    // do something useful
}];