<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableIndexSet",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableIndexSet"
  },
  "title" : "NSMutableIndexSet"
}
-->

# NSMutableIndexSet

A mutable collection of unique integer values that represent indexes in another collection.

```
class NSMutableIndexSet
```

## Overview

In Swift, this type bridges to [`IndexSet`](/documentation/Foundation/IndexSet); use [`NSMutableIndexSet`](/documentation/Foundation/NSMutableIndexSet) when you need reference semantics or other Foundation-specific behavior.

The [`NSMutableIndexSet`](/documentation/Foundation/NSMutableIndexSet) class represents a mutable collection of unique unsigned integers, known as *indexes* because of the way they are used. This collection is referred to as a *mutable index set*. The inclusive range of valid indexes is `0...(NSNotFound - 1)`; trying to use indexes outside this range is invalid.

The values in a mutable index set are always sorted, so the order in which values are added is irrelevant.

Do not subclass the [`NSMutableIndexSet`](/documentation/Foundation/NSMutableIndexSet) class.

> Important:
> The Swift overlay to the Foundation framework provides the ``doc://com.apple.foundation/documentation/Foundation/IndexSet`` structure, which bridges to the ``doc://com.apple.foundation/documentation/Foundation/NSMutableIndexSet`` class and its immutable superclass, ``doc://com.apple.foundation/documentation/Foundation/NSIndexSet``. For more information about value types, see <doc://com.apple.documentation/documentation/Swift/working-with-foundation-types>.

## Topics

### Adding Indexes

[`-  addIndex:`](/documentation/Foundation/NSMutableIndexSet/add(_:)-6dtkj)

Adds an index  to the receiver.

[`-  addIndexes:`](/documentation/Foundation/NSMutableIndexSet/add(_:)-6zmti)

Adds the indexes in an index set to the receiver.

[`-  addIndexesInRange:`](/documentation/Foundation/NSMutableIndexSet/add(in:))

Adds the indexes in an index range to the receiver.

### Removing Indexes

[`-  removeIndex:`](/documentation/Foundation/NSMutableIndexSet/remove(_:)-5li0r)

Removes an index from the receiver.

[`-  removeIndexes:`](/documentation/Foundation/NSMutableIndexSet/remove(_:)-196u2)

Removes the indexes in an index set from the receiver.

[`-  removeAllIndexes`](/documentation/Foundation/NSMutableIndexSet/removeAllIndexes())

Removes the receiver’s indexes.

[`-  removeIndexesInRange:`](/documentation/Foundation/NSMutableIndexSet/remove(in:))

Removes the indexes in an index range from the receiver.

### Shifting Index Groups

[`-  shiftIndexesStartingAtIndex:by:`](/documentation/Foundation/NSMutableIndexSet/shiftIndexesStarting(at:by:))

Shifts a group of indexes to the left or the right within the receiver.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Sequence`](/documentation/Swift/Sequence)

[`NSMutableCopying`](/documentation/Foundation/NSMutableCopying)

[`Sendable`](/documentation/Swift/Sendable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSIndexSet`](/documentation/Foundation/NSIndexSet)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)