---
title: withDictionary
framework: Kernel
role: symbol
role_heading: Type Method
platforms: [driverkit 19.0+, macOS 10.15+]
path: kernel/osdictionary/3180908-withdictionary
---

# withDictionary

Allocates an OSDictionary object with given members and preallocated capacity.

## Declaration

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

```occ
static OSPtr<OSDictionary> withDictionary(const OSDictionary *dict, unsigned int 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](kernel/osdictionary/3180907-withcapacity.md)
- [withObjects](kernel/osdictionary/3180909-withobjects.md)
- [merge](kernel/osdictionary/3180904-merge.md)
- [free](kernel/osdictionary/3180898-free.md)
- [flushCollection](kernel/osdictionary/3180897-flushcollection.md)
