---
title: "setDestination(_:allowOverwrite:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurldownload/setdestination(_:allowoverwrite:)"
---

# setDestination(_:allowOverwrite:)

Sets the destination path of the downloaded file.

## Declaration

```swift
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

Discussion If allowOverwrite is 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:) 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

### Related Documentation

- [download(_:decideDestinationWithSuggestedFilename:)](foundation/nsurldownloaddelegate/download(_:decidedestinationwithsuggestedfilename:).md)
- [download(_:didCreateDestination:)](foundation/nsurldownloaddelegate/download(_:didcreatedestination:).md)

### Creating and configuring a download instance

- [init(request:delegate:)](foundation/nsurldownload/init(request:delegate:).md)
