<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ManagedBufferPointer/init(bufferClass:minimumCapacity:makingHeaderWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s20ManagedBufferPointerVsRi__rlE11bufferClass15minimumCapacity16makingHeaderWithAByxq_GyXlXp_SixyXl_SiyXlXEtKXEtKcfc"
  },
  "title" : "init(bufferClass:minimumCapacity:makingHeaderWith:)"
}
-->

# init(bufferClass:minimumCapacity:makingHeaderWith:)

Create with new storage containing an initial `Header` and space
for at least `minimumCapacity` `element`s.

```
init(bufferClass: AnyClass, minimumCapacity: Int, makingHeaderWith factory: (AnyObject, (AnyObject) -> Int) throws -> Header) rethrows
```

## Parameters

`bufferClass`

The class of the object used for storage.

`minimumCapacity`

The minimum number of `Element`s that
must be able to be stored in the new buffer.

`factory`

A function that produces the initial
`Header` instance stored in the buffer, given the `buffer`
object and a function that can be called on it to get the actual
number of allocated elements.

## Discussion> Precondition: `minimumCapacity >= 0`, and the type indicated by
> `bufferClass` is a non-`@objc` class with no declared stored
> properties.  The `deinit` of `bufferClass` must destroy its
> stored `Header` and any constructed `Element`s.

---

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)