---
title: "setValue(_:forInputKey:)"
framework: quartz
role: symbol
role_heading: Instance Method
path: "quartz/qccompositionrenderer/setvalue(_:forinputkey:)"
---

# setValue(_:forInputKey:)

Sets the value for an input port of a composition.

## Declaration

```swift
func setValue(_ value: Any!, forInputKey key: String!) -> Bool
```

## Parameters

- `value`: The value to set for the input port. The input port must be at the root patch of the composition. The data type of the value argument must match the input port. See doc://com.apple.quartz/documentation/Quartz/QCPortAttributeTypeKey for the data types accepted by a particular port type.
- `key`: The key associated with the input port of the composition. This method throws an exception if key is invalid.

## Return Value

Return Value Returns false if it cannot set the value.

## See Also

### Passing and Retrieving Values From a Composition

- [value(forInputKey:)](quartz/qccompositionrenderer/value(forinputkey:).md)
- [value(forOutputKey:)](quartz/qccompositionrenderer/value(foroutputkey:).md)
- [value(forOutputKey:ofType:)](quartz/qccompositionrenderer/value(foroutputkey:oftype:).md)
