---
title: "objc_enumerationMutation(_:)"
framework: Objective-C Runtime
role: symbol
role_heading: Function
platforms: [iOS 2.0+, iPadOS 2.0+, Mac Catalyst 13.1+, macOS 10.5+, tvOS 9.0+, visionOS 1.0+, watchOS 1.0+]
path: "objectivec/objc_enumerationmutation(_:)"
---

# objc_enumerationMutation(_:)

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

## Declaration

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

## Parameters

- `obj`: The object being mutated.

## Discussion

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(_:) function). If the handler is not set up, a fatal error occurs.

## See Also

### Using Objective-C Language Features

- [objc_setEnumerationMutationHandler(_:)](objectivec/objc_setenumerationmutationhandler(_:).md)
- [imp_implementationWithBlock(_:)](objectivec/imp_implementationwithblock(_:).md)
- [imp_getBlock(_:)](objectivec/imp_getblock(_:).md)
- [imp_removeBlock(_:)](objectivec/imp_removeblock(_:).md)
- [objc_loadWeak(_:)](objectivec/objc_loadweak(_:).md)
- [objc_storeWeak(_:_:)](objectivec/objc_storeweak(_:_:).md)
