---
title: "animation(forKey:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsanimatablepropertycontainer/animation(forkey:)"
---

# animation(forKey:)

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

## Declaration

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

## Parameters

- `key`: The action name or property specified as a string.

## Return Value

Return Value The animation to perform. A subclass of CAAnimation.

## Discussion

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 CALayer counterpart, 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() for the receiver’s class. Subclasses should not typically need to override this method.

## See Also

### Related Documentation

- [animator()](appkit/nsanimatablepropertycontainer/animator().md)

### Managing Animations for Properties

- [animations](appkit/nsanimatablepropertycontainer/animations.md)
- [defaultAnimation(forKey:)](appkit/nsanimatablepropertycontainer/defaultanimation(forkey:).md)
- [NSAnimatablePropertyKey](appkit/nsanimatablepropertykey.md)
