<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/willChange(_:valuesAt:forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)willChange:valuesAtIndexes:forKey:"
  },
  "title" : "willChange(_:valuesAt:forKey:)"
}
-->

# willChange(_:valuesAt:forKey:)

Informs the observed object that the specified change is about to be executed at given indexes for a specified ordered to-many relationship.

```
func willChange(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, forKey key: String)
```

## Parameters

`changeKind`

The type of change that is about to be made.

`indexes`

The indexes of the to-many relationship that will be affected by the change.

`key`

The name of a property that is an ordered to-many relationship.

## Discussion

Use this method when implementing key-value-observing compliance manually.

> Important:
> After the values have been changed, a corresponding ``doc://com.apple.objectivec/documentation/ObjectiveC/NSObject-swift.class/didChange(_:valuesAt:forKey:)`` must be invoked with the same parameters.

### Special Considerations

You rarely need to override this method in subclasses, but if you do, be sure to call `super`.

---

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)