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

# setObjectSamplerState(_:index:)

Assigns a sampler state to an entry in the object shader argument table.

## Declaration

```swift
func setObjectSamplerState(_ sampler: (any MTLSamplerState)?, index: Int)
```

## Parameters

- `sampler`: An doc://com.apple.metal/documentation/Metal/MTLSamplerState instance the command assigns to an entry in the object shader argument table for sampler states.
- `index`: An integer that represents the entry in the object argument table for sampler states that stores a record of sampler.

## Discussion

Discussion By default, the sampler state at each index is nil.

## See Also

### Assigning sampler states for object shaders

- [setObjectSamplerState(_:lodMinClamp:lodMaxClamp:index:)](metal/mtlrendercommandencoder/setobjectsamplerstate(_:lodminclamp:lodmaxclamp:index:).md)
- [setObjectSamplerStates(_:range:)](metal/mtlrendercommandencoder/setobjectsamplerstates(_:range:).md)
- [setObjectSamplerStates(_:lodMinClamps:lodMaxClamps:range:)](metal/mtlrendercommandencoder/setobjectsamplerstates(_:lodminclamps:lodmaxclamps:range:).md)
