---
title: objectEnumerator()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nscountedset/objectenumerator()
---

# objectEnumerator()

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

## Declaration

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

## Return Value

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

## Discussion

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 method to create a “snapshot,” then enumerate the snapshot and modify the original set.

## See Also

### Related Documentation

- [nextObject()](foundation/nsenumerator/nextobject().md)

### Examining a Counted Set

- [count(for:)](foundation/nscountedset/count(for:).md)
