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

# animation(forKey:)

Returns the animation with the specified key.

## Declaration

```swift
func animation(forKey key: String) -> CAAnimation?
```

## Parameters

- `key`: A string identifying a previously added animation.

## Return Value

Return Value An animation object matching the key, or nil if no such animation exists.

## Discussion

Discussion Attempting to modify any properties of the returned object results in undefined behavior.

## See Also

### Managing Animations

- [addAnimation(_:forKey:)](scenekit/scnanimatable/addanimation(_:forkey:).md)
- [animationKeys](scenekit/scnanimatable/animationkeys.md)
- [removeAllAnimations()](scenekit/scnanimatable/removeallanimations().md)
- [removeAnimation(forKey:)](scenekit/scnanimatable/removeanimation(forkey:).md)
- [removeAnimation(forKey:fadeOutDuration:)](scenekit/scnanimatable/removeanimation(forkey:fadeoutduration:).md)
