---
title: "init(capacity:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsmutabledictionary/init(capacity:)"
---

# init(capacity:)

Initializes a newly allocated mutable dictionary, allocating enough memory to hold numItems entries.

## Declaration

```swift
init(capacity numItems: Int)
```

## Parameters

- `numItems`: The initial capacity of the initialized dictionary.

## Return Value

Return Value An initialized mutable dictionary, which might be different than the original receiver.

## Discussion

Discussion Mutable dictionaries allocate additional memory as needed, so numItems simply establishes the object’s initial capacity. This method is a designated initializer of NSMutableDictionary.

## See Also

### Creating and Initializing a Mutable Dictionary

- [init()](foundation/nsmutabledictionary/init().md)
- [init(sharedKeySet:)](foundation/nsmutabledictionary/init(sharedkeyset:).md)
