---
title: withCapacity
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osdictionary/withcapacity
---

# withCapacity

Allocates an OSDictionary object with preallocated capacity.

## Declaration

```occ
static OSDictionaryPtr withCapacity(uint32_t capacity);
```

## Parameters

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

- [withDictionary](driverkit/osdictionary/withdictionary.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)
