<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDocument/revert(toContentsOf:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDocument(im)revertToContentsOfURL:completionHandler:"
  },
  "title" : "revert(toContentsOf:completionHandler:)"
}
-->

# revert(toContentsOf:completionHandler:)

Reverts a document to the most recent document data stored on-disk.

```
func revert(toContentsOf url: URL, completionHandler: (@Sendable (Bool) -> Void)? = nil)
```

## Parameters

`url`

A file URL locating the most recent version of the document file in the application’s sandbox.

`completionHandler`

A block with code to execute after the reversion operation concludes. The block returns no value and has one parameter:

- `success`: <doc://com.apple.documentation/documentation/Swift/true> if the reversion operation succeeds, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

    The block is invoked on the main queue.

## Discussion

You call this method to discard all unsaved document modifications and replace the document’s contents by reading the file or file package located by `url`. The default implementation brackets the reversion operation between [`disableEditing()`](/documentation/UIKit/UIDocument/disableEditing()) and [`enableEditing()`](/documentation/UIKit/UIDocument/enableEditing())because the document shouldn’t accept user changes during this period. Subclasses that override this method must call the superclass implementation (`super`) or use the <doc://com.apple.documentation/documentation/Foundation/NSFileCoordinator> class to initiate a coordinated read.

---

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)