---
title: "setColorStoreAction(_:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/setcolorstoreaction(_:index:)"
---

# setColorStoreAction(_:index:)

Configures the store action for a color attachment.

## Declaration

```swift
func setColorStoreAction(_ storeAction: MTLStoreAction, index colorAttachmentIndex: Int)
```

## Parameters

- `storeAction`: A store action for the color attachment that can’t be doc://com.apple.metal/documentation/Metal/MTLStoreAction/unknown.
- `colorAttachmentIndex`: The index of a color attachment.

## Discussion

Discussion This method changes the render command encoder’s store action for a color attachment. You can assign the default store action for a color attachment by configuring the storeAction property of its MTLRenderPassColorAttachmentDescriptor (see MTLRenderPassDescriptor and its colorAttachments property). important: You need to call this method before calling the encoder’s endEncoding() method, but only for color attachments with a storeAction property equal to MTLStoreAction.unknown.

## See Also

### Configuring the actions for attachments

- [setColorStoreActionOptions(_:index:)](metal/mtlrendercommandencoder/setcolorstoreactionoptions(_:index:).md)
- [setDepthStoreAction(_:)](metal/mtlrendercommandencoder/setdepthstoreaction(_:).md)
- [setDepthStoreActionOptions(_:)](metal/mtlrendercommandencoder/setdepthstoreactionoptions(_:).md)
- [setStencilStoreAction(_:)](metal/mtlrendercommandencoder/setstencilstoreaction(_:).md)
- [setStencilStoreActionOptions(_:)](metal/mtlrendercommandencoder/setstencilstoreactionoptions(_:).md)
