<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAnimatablePropertyContainer/animation(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSAnimatablePropertyContainer(im)animationForKey:"
  },
  "title" : "animation(forKey:)"
}
-->

# animation(forKey:)

Returns the animation that should be performed for the specified key.

```
func animation(forKey key: NSAnimatablePropertyKey) -> Any?
```

## Parameters

`key`

The action name or property specified as a string.

## Return Value

The animation to perform. A subclass of <doc://com.apple.documentation/documentation/QuartzCore/CAAnimation>.

## Discussion

When the action specified by `key` is triggered for an object, this method is consulted to find the animation, if any, that should be performed in response.

Like its Core Animation <doc://com.apple.documentation/documentation/QuartzCore/CALayer> counterpart, <doc://com.apple.documentation/documentation/QuartzCore/CALayer/action(forKey:)>, this method is a funnel point that defines the order in which the search for an animation proceeds.It first checks the receiver’s Getting the Animator Proxy dictionary for a value matching `key`, then falls back to  [`animator()`](/documentation/AppKit/NSAnimatablePropertyContainer/animator()) for the receiver’s class.

Subclasses should not typically need to override this method.

## See Also

[`-  animator`](/documentation/AppKit/NSAnimatablePropertyContainer/animator())

Returns a proxy object for the receiver that can be used to initiate implied animation for property changes.



---

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)