<!--
{
  "availability" : [
    "iOS: 8.0.0 - 26.0.0",
    "iPadOS: 8.0.0 - 26.0.0",
    "macCatalyst: 13.1.0 - 26.0.0",
    "macOS: 10.8.0 - 26.0.0",
    "tvOS: 9.0.0 - 26.0.0",
    "visionOS: 1.0.0 - 26.0.0",
    "watchOS: 3.0.0 - 26.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SceneKit",
  "identifier" : "/documentation/SceneKit/SCNLight/attribute(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SceneKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SCNLight(im)attributeForKey:"
  },
  "title" : "attribute(forKey:)"
}
-->

# attribute(forKey:)

Returns the value of a lighting attribute.

```
func attribute(forKey key: String) -> Any?
```

## Parameters

`key`

A constant specifying a lighting attribute. See [Lighting Attribute Keys](/documentation/SceneKit/lighting-attribute-keys) for available keys and their possible values.

## Return Value

The value of the lighting attribute, or `nil` if no such attribute exists.

## Discussion

A light’s [`type`](/documentation/SceneKit/SCNLight/type) property determines its set of available attributes.

You can also get the values of lighting attributes using [Key-value coding](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/KeyValueCoding.html#//apple_ref/doc/uid/TP40008195-CH25). The key path for each lighting attribute is listed in [Lighting Attribute Keys](/documentation/SceneKit/lighting-attribute-keys).

---

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)