<!--
{
  "availability" : [
    "iOS: 11.0.0 - 27.0.0",
    "iPadOS: 11.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 11.0.0 - 27.0.0",
    "tvOS: 11.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "ReplayKit",
  "identifier" : "/documentation/ReplayKit/RPScreenRecorderDelegate/screenRecorder(_:didStopRecordingWith:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ReplayKit"
    ],
    "preciseIdentifier" : "c:objc(pl)RPScreenRecorderDelegate(im)screenRecorder:didStopRecordingWithPreviewViewController:error:"
  },
  "title" : "screenRecorder(_:didStopRecordingWith:error:)"
}
-->

# screenRecorder(_:didStopRecordingWith:error:)

Indicates that the screen recording has stopped.

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

## Parameters

`screenRecorder`

The [`RPScreenRecorder`](/documentation/ReplayKit/RPScreenRecorder) instance.

`previewViewController`

An [`RPPreviewViewController`](/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

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`](/documentation/ReplayKit/RPPreviewViewController) is returned.

---

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)