<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLMesh/addAttribute(withName:format:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O",
      "ModelIO"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLMesh(im)addAttributeWithName:format:"
  },
  "title" : "addAttribute(withName:format:)"
}
-->

# addAttribute(withName:format:)

Adds a vertex attribute to the mesh and creates a new, empty corresponding vertex buffer.

```
func addAttribute(withName name: String, format: MDLVertexFormat)
```

## Parameters

`name`

A name for the new attribute. See Vertex Attributes for standard attribute names.

`format`

The data format for the new attribute.

## Discussion

Calling this method updates the mesh’s [`vertexDescriptor`](/documentation/ModelIO/MDLMesh/vertexDescriptor) object to reflect the new attribute, and then uses the same [`MDLMeshBufferAllocator`](/documentation/ModelIO/MDLMeshBufferAllocator) object shared by the mesh’s existing vertex buffers to allocate new, empty storage for the new attribute’s vertex data. This method has no effect if the mesh already contains an attribute with the specified name; to overwrite or rearrange existing attribute data, use the [`vertexDescriptor`](/documentation/ModelIO/MDLMesh/vertexDescriptor) property.

---

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)