---
title: "init(bufferClass:minimumCapacity:makingHeaderWith:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/managedbufferpointer/init(bufferclass:minimumcapacity:makingheaderwith:)"
---

# init(bufferClass:minimumCapacity:makingHeaderWith:)

Create with new storage containing an initial Header and space for at least minimumCapacity elements.

## Declaration

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

Discussion note: 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 Elements.

## See Also

### Creating a Buffer

- [init(unsafeBufferObject:)](swift/managedbufferpointer/init(unsafebufferobject:).md)
