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

# objectEnumerator()

Returns an enumerator object that lets you access each object in the set once, independent of its count.

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

## Return Value

An enumerator object that lets you access each object in the set once, independent of its count.

## Discussion

If you add a given object to the counted set multiple times, an enumeration of the set will produce that object only once.

You shouldn’t modify the set during enumeration. If you intend to modify the set, use the [`allObjects`](/documentation/Foundation/NSSet/allObjects) method to create a “snapshot,” then enumerate the snapshot and modify the original set.

## See Also

[`func nextObject() -> Any?`](/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)