<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioRecorder/record(forDuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioRecorder(im)recordForDuration:"
  },
  "title" : "record(forDuration:)"
}
-->

# record(forDuration:)

Records audio for the indicated duration of time.

```
func record(forDuration duration: TimeInterval) -> Bool
```

## Parameters

`duration`

The duration of time to record, in seconds.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if successful; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

The recorder stops recording when it reaches the indicated duration.

Calling this method implicitly calls [`prepareToRecord()`](/documentation/AVFAudio/AVAudioRecorder/prepareToRecord()), which creates an audio file and prepares the system for recording.

---

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)