<!--
{
  "availability" : [
    "macOS: 10.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLDownload/setDestination(_:allowOverwrite:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLDownload(im)setDestination:allowOverwrite:"
  },
  "title" : "setDestination(_:allowOverwrite:)"
}
-->

# setDestination(_:allowOverwrite:)

Sets the destination path of the downloaded file.

```
func setDestination(_ path: String, allowOverwrite: Bool)
```

## Parameters

`path`

The path for the downloaded file.

`allowOverwrite`

<doc://com.apple.documentation/documentation/Swift/true> if an existing file at `path` can be replaced, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

If `allowOverwrite` is <doc://com.apple.documentation/documentation/Swift/false> and a file already exists at `path`, a unique filename will be created for the downloaded file by appending a number to the filename. The delegate can implement the [`download(_:didCreateDestination:)`](/documentation/Foundation/NSURLDownloadDelegate/download(_:didCreateDestination:)) delegate method to determine the filename used when the file is written to disk.

### Special Considerations

An `NSURLDownload` instance ignores multiple calls to this method.

## See Also

[`-  download:decideDestinationWithSuggestedFilename:`](/documentation/Foundation/NSURLDownloadDelegate/download(_:decideDestinationWithSuggestedFilename:))

The delegate receives this message when `download` has determined a suggested filename for the downloaded file.

[`-  download:didCreateDestination:`](/documentation/Foundation/NSURLDownloadDelegate/download(_:didCreateDestination:))

Sent when the destination file is created.



---

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)