<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSSet/withCapacity",
  "metadataVersion" : "0.1.0",
  "role" : "Static Method",
  "symbol" : {
    "kind" : "Static Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSSet@F@withCapacity#i#S"
  },
  "title" : "withCapacity"
}
-->

# withCapacity

```
static OSSetPtr withCapacity(uint32_t capacity);
```

## Parameters

`capacity`

Count of allocated capacity for members in array.

## Return Value

NULL on failure, otherwise the allocated OSSet with reference count 1 to be released by the caller.

## Discussion\abstract Allocates an OSSet object with preallocated 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)