---
title: "autosave(withDelegate:didAutosave:contextInfo:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/autosave(withdelegate:didautosave:contextinfo:)"
---

# autosave(withDelegate:didAutosave:contextInfo:)

Autosaves the document’s contents to an appropriate location in the file system.

## Declaration

```swift
func autosave(withDelegate delegate: Any?, didAutosave didAutosaveSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)
```

## Parameters

- `delegate`: The delegate to which the selector message is sent.
- `didAutosaveSelector`: The selector of the message sent to the delegate.
- `contextInfo`: Object passed with the callback to provide any additional context information.

## Discussion

Discussion After autosaving, sends the message selected by didAutosaveSelector to the delegate, with contextInfo as the last argument. The method selected by didAutosaveSelector must have the same signature as: - (void)document:(NSDocument *)document didAutosave:(BOOL)didAutosaveSuccessfully contextInfo:(void *)contextInfo If an error occurs while autosaving, the method reports it to the user before sending the delegate a succeeded:NO message.

## See Also

### Related Documentation

- [autosavedContentsFileURL](appkit/nsdocument/autosavedcontentsfileurl.md)

### Autosaving the Document

- [checkAutosavingSafety()](appkit/nsdocument/checkautosavingsafety().md)
- [hasUnautosavedChanges](appkit/nsdocument/hasunautosavedchanges.md)
- [scheduleAutosaving()](appkit/nsdocument/scheduleautosaving().md)
- [autosave(withImplicitCancellability:completionHandler:)](appkit/nsdocument/autosave(withimplicitcancellability:completionhandler:).md)
- [backupFileURL](appkit/nsdocument/backupfileurl.md)
