---
title: "startCapture(handler:completionHandler:)"
framework: replaykit
role: symbol
role_heading: Instance Method
path: "replaykit/rpscreenrecorder/startcapture(handler:completionhandler:)"
---

# startCapture(handler:completionHandler:)

Starts screen and audio capture.

## Declaration

```swift
func startCapture(handler captureHandler: ((CMSampleBuffer, RPSampleBufferType, (any Error)?) -> Void)?, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func startCapture(handler captureHandler: ((CMSampleBuffer, RPSampleBufferType, (any Error)?) -> Void)?) async throws
```

## Parameters

- `captureHandler`: A block that is called continuously during screen capture.
- `completionHandler`: A block that is called when screen capture has started.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func startCapture(handler captureHandler: ((CMSampleBuffer, RPSampleBufferType, Error?) -> Void)?) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Controlling App Recording

- [startRecording(handler:)](replaykit/rpscreenrecorder/startrecording(handler:).md)
- [stopRecording(handler:)](replaykit/rpscreenrecorder/stoprecording(handler:).md)
- [stopRecording(withOutput:completionHandler:)](replaykit/rpscreenrecorder/stoprecording(withoutput:completionhandler:).md)
- [RPSampleBufferType](replaykit/rpsamplebuffertype.md)
- [stopCapture(handler:)](replaykit/rpscreenrecorder/stopcapture(handler:).md)
- [discardRecording(handler:)](replaykit/rpscreenrecorder/discardrecording(handler:).md)
- [startRecording(withMicrophoneEnabled:handler:)](replaykit/rpscreenrecorder/startrecording(withmicrophoneenabled:handler:).md)
