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

# NSRelativeSpecifier

A specifier that indicates an object in a collection by its position relative to another object.

```
class NSRelativeSpecifier
```

## Overview

You don’t normally subclass `NSRelativeSpecifier`.

## Topics

### Initializing a relative specifier

[`-  initWithContainerClassDescription:containerSpecifier:key:relativePosition:baseSpecifier:`](/documentation/Foundation/NSRelativeSpecifier/init(containerClassDescription:containerSpecifier:key:relativePosition:baseSpecifier:))

Invokes the super class’s [`init(containerClassDescription:containerSpecifier:key:)`](/documentation/Foundation/NSScriptObjectSpecifier/init(containerClassDescription:containerSpecifier:key:)) method and initializes the relative position and base specifier to `relPos` and `baseSpecifier`.

### Accessing a relative specifier

[`baseSpecifier`](/documentation/Foundation/NSRelativeSpecifier/baseSpecifier)

Sets the specifier for the base object.

[`relativePosition`](/documentation/Foundation/NSRelativeSpecifier/relativePosition-swift.property)

Sets the relative position encapsulated by the receiver.

### Constants

[`RelativePosition`](/documentation/Foundation/NSRelativeSpecifier/RelativePosition-swift.enum)

These constants are used by [`relativePosition`](/documentation/Foundation/NSRelativeSpecifier/relativePosition-swift.property) and [`relativePosition`](/documentation/Foundation/NSRelativeSpecifier/relativePosition-swift.property).

## Relationships

### Conforms To

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

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

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

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

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

[`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)