---
title: withDictionary
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osdictionary/withdictionary
---

# withDictionary

Allocates an OSDictionary object with given members and preallocated capacity.

## Declaration

```occ
static OSDictionaryPtr withDictionary(const OSDictionary *dictionary, uint32_t capacity);
```

## Parameters

- `dictionary`: Dictionary object containing members for the new dictionary.
- `capacity`: Count of allocated capacity for members in array.

## 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)
- [withObjects](driverkit/osdictionary/withobjects.md)
- [OSDictionaryCreate](driverkit/osdictionarycreate.md)
- [merge](driverkit/osdictionary/merge.md)
- [free](driverkit/osdictionary/free.md)
- [flushCollection](driverkit/osdictionary/flushcollection.md)
