<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSHashTable/objectEnumerator()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHashTable(im)objectEnumerator"
  },
  "title" : "objectEnumerator()"
}
-->

# objectEnumerator()

Returns an enumerator object that lets you access each object in the hash table.

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

## Return Value

An enumerator object that lets you access each object in the hash table.

## Discussion

The following code fragment illustrates how you can use this method.

```objc
NSEnumerator *enumerator = [myHashTable objectEnumerator];
id value;
 
while ((value = [enumerator nextObject])) {
    /* code that acts on the hash table's values */
}
```

### Special Considerations

It is more efficient to use the fast enumeration protocol (see [`NSFastEnumeration`](/documentation/Foundation/NSFastEnumeration)).

---

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)