---
title: "screenRecorder(_:didStopRecordingWith:error:)"
framework: replaykit
role: symbol
role_heading: Instance Method
path: "replaykit/rpscreenrecorderdelegate/screenrecorder(_:didstoprecordingwith:error:)"
---

# screenRecorder(_:didStopRecordingWith:error:)

Indicates that the screen recording has stopped.

## Declaration

```swift
optional func screenRecorder(_ screenRecorder: RPScreenRecorder, didStopRecordingWith previewViewController: RPPreviewViewController?, error: (any Error)?)
```

## Parameters

- `screenRecorder`: The doc://com.apple.replaykit/documentation/ReplayKit/RPScreenRecorder instance.
- `previewViewController`: An doc://com.apple.replaykit/documentation/ReplayKit/RPPreviewViewController interface object that is returned if anything at all was recorded. The interface allows the user to preview and edit the recording.
- `error`: An doc://com.apple.documentation/documentation/Foundation/NSError describing why the recording stopped. This method is nil when no error occurs.

## Discussion

Discussion This method is called when recording stops due to an error or a change in recording availability. If any part of the stopped recording is available, an instance of RPPreviewViewController is returned.

## See Also

### Responding to Recording Changes

- [screenRecorderDidChangeAvailability(_:)](replaykit/rpscreenrecorderdelegate/screenrecorderdidchangeavailability(_:).md)
- [screenRecorder(_:didStopRecordingWithError:previewViewController:)](replaykit/rpscreenrecorderdelegate/screenrecorder(_:didstoprecordingwitherror:previewviewcontroller:).md)
