<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/objc_enumerationMutation(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:@F@objc_enumerationMutation"
  },
  "title" : "objc_enumerationMutation(_:)"
}
-->

# objc_enumerationMutation(_:)

Inserted by the compiler when a mutation is detected during a foreach iteration.

```
func objc_enumerationMutation(_ obj: Any)
```

## Parameters

`obj`

The object being mutated.

## Discussion

The compiler inserts this function when it detects that an object is mutated during a foreach iteration. The function is called when a mutation occurs, and the enumeration mutation handler is enacted if it is set up (via the [`objc_setEnumerationMutationHandler(_:)`](/documentation/ObjectiveC/objc_setEnumerationMutationHandler(_:)) function). If the handler is not set up, a fatal error occurs.

---

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)