---
title: "move(to:completionHandler:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/move(to:completionhandler:)"
---

# move(to:completionHandler:)

Moves the document’s file to the given URL.

## Declaration

```swift
func move(to url: URL, completionHandler: (((any Error)?) -> Void)? = nil)
```

```swift
func move(to url: URL) async throws
```

## Parameters

- `url`: The location where the file will ultimately end up, if the move is successful.
- `completionHandler`: The completion handler block object passed in to be invoked at some point in the future, perhaps after the method invocation has returned. The completion handler must be invoked on the main thread. On output, a nil error is passed if the move is successful; otherwise an doc://com.apple.documentation/documentation/Foundation/NSError object is passed that encapsulates the reason for failure.

## Discussion

Discussion The default implementation of this method replaces any file that may currently exist at the given URL with the one being moved, as necessary.

## See Also

### Related Documentation

- [moveToUbiquityContainer(_:)](appkit/nsdocument/movetoubiquitycontainer(_:).md)

### Moving the Document

- [move(_:)](appkit/nsdocument/move(_:).md)
- [move(completionHandler:)](appkit/nsdocument/move(completionhandler:).md)
