---
title: "revert(toContentsOf:ofType:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspersistentdocument/revert(tocontentsof:oftype:)"
---

# revert(toContentsOf:ofType:)

Overridden to clean up the managed object context and controllers during a revert.

## Declaration

```swift
func revert(toContentsOf inAbsoluteURL: URL, ofType inTypeName: String) throws
```

## Parameters

- `inAbsoluteURL`: An URL object that specifies the location of the file to which to revert.
- `inTypeName`: The type of the document at inAbsoluteURL.

## Discussion

Discussion note: In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Document Content Management

- [read(from:ofType:)](appkit/nspersistentdocument/read(from:oftype:).md)
- [write(to:ofType:for:originalContentsURL:)](appkit/nspersistentdocument/write(to:oftype:for:originalcontentsurl:).md)
