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

# record(atTime:forDuration:)

Records audio starting at a specific time for the indicated duration.

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

## Parameters

`time`

The time at which to start recording, relative to [`deviceCurrentTime`](/documentation/AVFAudio/AVAudioRecorder/deviceCurrentTime).

`duration`

The duration of time to record, in seconds.

## Return Value

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

## Discussion

The recorder automatically stops recording when it reaches the indicated duration. You may also use it to synchronize recording of multiple recorders as shown below.

```swift
func startSynchronizedRecording() {
    // Create a start time relative to the current device time.
    let time = recorderOne.deviceCurrentTime + 0.01
    let duration: TimeInterval = 10.0
    
    // Synchronize recording of both recorders.
    recorderOne.record(atTime: time, forDuration: duration)
    recorderTwo.record(atTime: time, forDuration: 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)