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

# download(_:decideDestinationWithSuggestedFilename:)

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

```
optional func download(_ download: NSURLDownload, decideDestinationWithSuggestedFilename filename: String)
```

## Parameters

`download`

The URL download object sending the message.

`filename`

The suggested filename for the download.

## Discussion

The suggested filename is either derived from the last path component of the URL and the MIME type or, if the download was encoded, from the encoding. If the delegate wishes to modify the path, it should send [`setDestination(_:allowOverwrite:)`](/documentation/Foundation/NSURLDownload/setDestination(_:allowOverwrite:)) to `download`.

### Special Considerations

The delegate will not receive this message if `setDestination:allowOverwrite:` has already been called for the download.

---

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)