---
title: anyObject()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nsset/anyobject()
---

# anyObject()

Returns one of the objects in the set, or nil if the set contains no objects.

## Declaration

```swift
func anyObject() -> Any?
```

## Return Value

Return Value One of the objects in the set, or nil if the set contains no objects. The object returned is chosen at the set’s convenience—the selection is not guaranteed to be random.

## See Also

### Accessing Set Members

- [allObjects](foundation/nsset/allobjects.md)
- [contains(_:)](foundation/nsset/contains(_:).md)
- [filtered(using:)](foundation/nsset/filtered(using:).md)
- [member(_:)](foundation/nsset/member(_:).md)
- [objectEnumerator()](foundation/nsset/objectenumerator().md)
- [enumerateObjects(_:)](foundation/nsset/enumerateobjects(_:).md)
- [enumerateObjects(options:using:)](foundation/nsset/enumerateobjects(options:using:).md)
- [objects(passingTest:)](foundation/nsset/objects(passingtest:).md)
- [objects(options:passingTest:)](foundation/nsset/objects(options:passingtest:).md)
