---
title: "setConstantValues(_:type:range:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlfunctionconstantvalues/setconstantvalues(_:type:range:)"
---

# setConstantValues(_:type:range:)

Sets values for a group of function constants within a specific index range.

## Declaration

```swift
func setConstantValues(_ values: UnsafeRawPointer, type: MTLDataType, range: Range<Int>)
```

## Parameters

- `values`: A pointer to the constant values.
- `type`: The data type of the function constants.
- `range`: The range of the function constant indices.

## Discussion

Discussion Declare multiple function constants in Metal Shading Language (MSL). constant bool a [[ function_constant(0) ]]; constant bool b [[ function_constant(1) ]]; constant bool c [[ function_constant(2) ]]; Set their values by assigning an index range of an array. let abc = [true, true, true] let constantValues = MTLFunctionConstantValues() constantValues.setConstantValues(abc,                                  type: .bool,                                  with: NSMakeRange(0, 3))

## See Also

### Setting constant values

- [setConstantValue(_:type:index:)](metal/mtlfunctionconstantvalues/setconstantvalue(_:type:index:).md)
- [setConstantValue(_:type:withName:)](metal/mtlfunctionconstantvalues/setconstantvalue(_:type:withname:).md)
