<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLRenderCommandEncoder/setColorStoreAction(_:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLRenderCommandEncoder(im)setColorStoreAction:atIndex:"
  },
  "title" : "setColorStoreAction(_:index:)"
}
-->

# setColorStoreAction(_:index:)

Configures the store action for a color attachment.

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

## Parameters

`storeAction`

A store action for the color attachment that can’t be [`MTLStoreAction.unknown`](/documentation/Metal/MTLStoreAction/unknown).

`colorAttachmentIndex`

The index of a color attachment.

## 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`](/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeAction) property of its [`MTLRenderPassColorAttachmentDescriptor`](/documentation/Metal/MTLRenderPassColorAttachmentDescriptor) (see [`MTLRenderPassDescriptor`](/documentation/Metal/MTLRenderPassDescriptor) and its [`colorAttachments`](/documentation/Metal/MTLRenderPassDescriptor/colorAttachments) property).

> Important:
> You need to call this method before calling the encoder’s ``doc://com.apple.metal/documentation/Metal/MTLCommandEncoder/endEncoding()`` method, but only for color attachments with a ``doc://com.apple.metal/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeAction`` property equal to ``doc://com.apple.metal/documentation/Metal/MTLStoreAction/unknown``.

---

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)