<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableOrderedSet/init(capacity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableOrderedSet(im)initWithCapacity:"
  },
  "title" : "init(capacity:)"
}
-->

# init(capacity:)

Returns an initialized mutable ordered set with a given initial capacity.

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

## Parameters

`numItems`

The initial capacity of the new ordered set.

## Return Value

An initialized mutable ordered set with initial capacity to hold `numItems` members.

## Discussion

Mutable ordered sets allocate additional memory as needed, so `numItems` simply establishes the set’s initial capacity.

This method is a designated initializer of `NSMutableOrderedSet`.

## See Also

[`+  orderedSetWithCapacity:`](/documentation/Foundation/NSMutableOrderedSet/orderedSetWithCapacity:)

Creates and returns an mutable ordered set with a given initial capacity.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)