<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLMeshBufferAllocator/newBuffer(with:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(pl)MDLMeshBufferAllocator(im)newBufferWithData:type:"
  },
  "title" : "newBuffer(with:type:)"
}
-->

# newBuffer(with:type:)

Creates a new buffer containing the specified data.

```
func newBuffer(with data: Data, type: MDLMeshBufferType) -> any MDLMeshBuffer
```

## Parameters

`data`

The initial data to store in the buffer. Implementations of this protocol typically copy this data.

`type`

Use [`MDLMeshBufferType.vertex`](/documentation/ModelIO/MDLMeshBufferType/vertex) to create a buffer for a mesh’s vertex attribute data, or [`MDLMeshBufferType.index`](/documentation/ModelIO/MDLMeshBufferType/index) to create a buffer for a submesh’s index data.

## Return Value

A new memory buffer for mesh data.

## Discussion

The concrete class implementing this protocol determines the memory pool from which the buffer is allocated. To provide a hint that multiple related allocations should share the same pool of memory, use the [`newBuffer(from:data:type:)`](/documentation/ModelIO/MDLMeshBufferAllocator/newBuffer(from:data:type:)) method instead.

---

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)