<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSDictionary/withObjects",
  "metadataVersion" : "0.1.0",
  "role" : "Static Method",
  "symbol" : {
    "kind" : "Static Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSDictionary@F@withObjects#**1$@S@OSObject#S0_#i#i#S"
  },
  "title" : "withObjects"
}
-->

# withObjects

Allocates an OSDictionary object with given members and preallocated capacity.

```
static OSDictionaryPtr withObjects(const OSObject **values, const OSObject **keys, uint32_t count, uint32_t capacity);
```

## Parameters

`values`

C-array pointer to values for the dictionary.

`keys`

C-array pointer to keys for the dictionary.

`count`

Count of members being added to the dictionary.

`capacity`

Count of allocated capacity for members in dictionary.

## Return Value

NULL on failure, otherwise the allocated OSDictionary with reference count 1 to be released by the caller.

---

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)