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

# download(_:didFailWithError:)

Sent if the download fails or if an I/O error occurs when the file is written to disk.

```
optional func download(_ download: NSURLDownload, didFailWithError error: any Error)
```

## Parameters

`download`

The URL download object sending the message.

`error`

The error that caused the failure of the download.

## Discussion

Any partially downloaded file will be deleted.

### Special Considerations

Once the delegate receives this message, it will receive no further messages for `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)