<!--
{
  "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/NSArray/addObserver(_:toObjectsAt:forKeyPath:options:context:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)addObserver:toObjectsAtIndexes:forKeyPath:options:context:"
  },
  "title" : "addObserver(_:toObjectsAt:forKeyPath:options:context:)"
}
-->

# addObserver(_:toObjectsAt:forKeyPath:options:context:)

Registers an observer to receive key value observer notifications for the specified key-path relative to the objects at the indexes.

```
func addObserver(_ observer: NSObject, toObjectsAt indexes: IndexSet, forKeyPath keyPath: String, options: NSKeyValueObservingOptions = [], context: UnsafeMutableRawPointer?)
```

## Parameters

`observer`

The observer.

`indexes`

The index set.

`keyPath`

The key path, relative to the array, to be observed.

`options`

The options to be included in the notification.

`context`

The context passed to the notifications.

## Discussion

The `options` determine what is included in the notifications, and the `context` is passed in the notifications.

This is not merely a convenience method; invoking this method is potentially much faster than repeatedly invoking <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/addObserver(_:forKeyPath:options:context:)>.

---

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)