<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSIndexSpecifier",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSIndexSpecifier"
  },
  "title" : "NSIndexSpecifier"
}
-->

# NSIndexSpecifier

A specifier representing an object in a collection (or container) with an index number.

```
class NSIndexSpecifier
```

## Overview

The script terms `first` and `front` specify the object with index `0`, while `last` specifies the object with index of `count-1`. A negative index indicates a location by counting backward from the last object in the collection.

You don’t normally subclass `NSIndexSpecifier`.

## Topics

### Creating Index Specifiers

[`-  initWithContainerClassDescription:containerSpecifier:key:index:`](/documentation/Foundation/NSIndexSpecifier/init(containerClassDescription:containerSpecifier:key:index:))

Initializes an allocated [`NSIndexSpecifier`](/documentation/Foundation/NSIndexSpecifier) object with a class description, container specifier, collection key, and object index.

### Accessing the Index

[`index`](/documentation/Foundation/NSIndexSpecifier/index)

Sets the value of the receiver’s `index` property.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)