<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAnimation/init(duration:animationCurve:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAnimation(im)initWithDuration:animationCurve:"
  },
  "title" : "init(duration:animationCurve:)"
}
-->

# init(duration:animationCurve:)

Returns an `NSAnimation` object initialized with the specified duration and animation-curve values.

```
init(duration: TimeInterval, animationCurve: NSAnimation.Curve)
```

## Parameters

`duration`

The number of seconds over which the animation occurs. Specifying a negative number raises an exception.

`animationCurve`

An `NSAnimationCurve` constant that describes the relative speed of the animation over its course; if it is zero, the default curve (`NSAnimationEaseInOut`) is used.

## Return Value

An initialized `NSAnimation` instance. Returns `nil` if the object could not be initialized.

## Discussion

You can always later change the duration of an `NSAnimation` object by changing the [`duration`](/documentation/AppKit/NSAnimation/duration) property, even while the animation is running. See “Constants” for descriptions of the NSAnimationCurve constants.

## See Also

[Drawing](/documentation/AppKit/drawing)

Draw shapes, images, and other content on the screen.

[`NSAnimation`](/documentation/AppKit/NSAnimation)

An object that manages the timing and progress of animations in the user interface.



---

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)