---
title: "setAttribute(_:forKey:)"
framework: scenekit
role: symbol
role_heading: Instance Method
path: "scenekit/scnlight/setattribute(_:forkey:)"
---

# setAttribute(_:forKey:)

Sets the value for a lighting attribute.

## Declaration

```swift
func setAttribute(_ attribute: Any?, forKey key: String)
```

## Parameters

- `attribute`: The value for the lighting attribute.
- `key`: A constant specifying a lighting attribute. See doc://com.apple.scenekit/documentation/SceneKit/lighting-attribute-keys for available keys and their possible values.

## Discussion

Discussion A light’s type property determines its set of available attributes. You can also set or animate changes to the values of lighting attributes using Key-value coding. The key path for each lighting attribute is listed in Lighting Attribute Keys.

## See Also

### Managing Light Attributes

- [name](scenekit/scnlight/name.md)
- [attribute(forKey:)](scenekit/scnlight/attribute(forkey:).md)
- [Lighting Attribute Keys](scenekit/lighting-attribute-keys.md)
