<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CALayer/defaultValue(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CALayer(cm)defaultValueForKey:"
  },
  "title" : "defaultValue(forKey:)"
}
-->

# defaultValue(forKey:)

Specifies the default value associated with the specified key.

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

## Parameters

`key`

The name of one of the receiver’s properties.

## Return Value

The default value for the named property. Returns `nil` if no default value has been set.

## Discussion

If you define custom properties for a layer but do not set a value, this method returns a suitable “zero” default value based on the expected value of the `key`. For example, if the value for `key` is a <doc://com.apple.documentation/documentation/CoreFoundation/CGSize> struct, the method returns a size struct containing (0.0,0.0) wrapped in an <doc://com.apple.documentation/documentation/Foundation/NSValue> object. For a <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> an empty rectangle is returned. For <doc://com.apple.documentation/documentation/CoreFoundation/CGAffineTransform> and [`CATransform3D`](/documentation/QuartzCore/CATransform3D), the appropriate identity matrix is returned.

### Special Considerations

If `key` is not a known for property of the class, the result of the method is undefined.

---

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)