---
title: withObjects
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osdictionary/withobjects
---

# withObjects

Allocates an OSDictionary object with given members and preallocated capacity.

## Declaration

```occ
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

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

## See Also

### Creating a Dictionary

- [withCapacity](driverkit/osdictionary/withcapacity.md)
- [withDictionary](driverkit/osdictionary/withdictionary.md)
- [OSDictionaryCreate](driverkit/osdictionarycreate.md)
- [merge](driverkit/osdictionary/merge.md)
- [free](driverkit/osdictionary/free.md)
- [flushCollection](driverkit/osdictionary/flushcollection.md)
