<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSSet/getAnyObject",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSSet@F@getAnyObject#1"
  },
  "title" : "getAnyObject"
}
-->

# getAnyObject

Returns an arbitrary (not random) object from the set.

```
OSObject * getAnyObject() const;
```

## Return Value

An arbitrary (not random) object if one exists within the set.

## Discussion

The returned object will be released if removed from the set; if you plan to store the reference, you should call retain on that object.

---

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)