---
title: "insertMaterial(_:at:)"
framework: scenekit
role: symbol
role_heading: Instance Method
path: "scenekit/scngeometry/insertmaterial(_:at:)"
---

# insertMaterial(_:at:)

Attaches a material to the geometry at the specified index.

## Declaration

```swift
func insertMaterial(_ material: SCNMaterial, at index: Int)
```

## Parameters

- `material`: The material to attach.
- `index`: The location in the geometry’s doc://com.apple.scenekit/documentation/SceneKit/SCNGeometry/materials array at which to add the new material. important: Raises an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException) if index is greater than the number of elements in the doc://com.apple.scenekit/documentation/SceneKit/SCNGeometry/materials array.

## See Also

### Managing a Geometry’s Materials

- [materials](scenekit/scngeometry/materials.md)
- [firstMaterial](scenekit/scngeometry/firstmaterial.md)
- [material(named:)](scenekit/scngeometry/material(named:).md)
- [removeMaterial(at:)](scenekit/scngeometry/removematerial(at:).md)
- [replaceMaterial(at:with:)](scenekit/scngeometry/replacematerial(at:with:).md)
