<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.4.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/saveToURL:ofType:forSaveOperation:error:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)saveToURL:ofType:forSaveOperation:error:"
  },
  "title" : "saveToURL:ofType:forSaveOperation:error:"
}
-->

# saveToURL:ofType:forSaveOperation:error:

Saves the contents of the document to a file or file package located by a URL, formatted to a specified type, for a particular kind of save operation.

```
- (BOOL) saveToURL:(NSURL *) url ofType:(NSString *) typeName forSaveOperation:(NSSaveOperationType) saveOperation error:(NSError **) outError;
```

## Parameters

`url`

The location of the file or file package to which the document contents are saved.

`typeName`

The string that identifies the document type.

`saveOperation`

The type of save operation.

`outError`

On return, if the document contents could not be saved, a pointer to an error object that encapsulates the reason they could not be saved.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the document contents were successfully saved; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

You can override this method to do things that need to be done before or after any save operation. If you override this method, you must call `super` at some point in your implementation.

---

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)