<!--
{
  "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/NSDictionary/objectEnumerator()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDictionary(im)objectEnumerator"
  },
  "title" : "objectEnumerator()"
}
-->

# objectEnumerator()

Returns an enumerator object that lets you access each value in the dictionary.

```
func objectEnumerator() -> NSEnumerator
```

## Return Value

An enumerator object that lets you access each value in the dictionary.

## Discussion

The following code fragment illustrates how you might use the method.

```objc
NSEnumerator *enumerator = [myDictionary objectEnumerator];
id value;
 
while ((value = [enumerator nextObject])) {
    /* code that acts on the dictionary’s values */
}
```

If you use this method with instances of mutable subclasses of `NSDictionary`, your code should not modify the entries during enumeration. If you intend to modify the entries, use the [`allValues`](/documentation/Foundation/NSDictionary/allValues) method to create a “snapshot” of the dictionary’s values. Work from this snapshot to modify the values.

### Special Considerations

It is more efficient to use the fast enumeration protocol (see [`NSFastEnumeration`](/documentation/Foundation/NSFastEnumeration)). Fast enumeration is available in macOS 10.5 and later and iOS 2.0 and later.

## See Also

[`-  nextObject`](/documentation/Foundation/NSEnumerator/nextObject())

Returns the next object from the collection being enumerated.



---

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)