---
title: "download(_:didCancel:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurldownloaddelegate/download(_:didcancel:)"
---

# download(_:didCancel:)

Sent if an authentication challenge is canceled due to the protocol implementation encountering an error.

## Declaration

```swift
optional func download(_ download: NSURLDownload, didCancel challenge: URLAuthenticationChallenge)
```

## Parameters

- `download`: The URL download object sending the message.
- `challenge`: The authentication challenge that caused the download object to cancel the download.

## Discussion

Discussion If the delegate receives this message the download will fail and the delegate will receive a download(_:didFailWithError:) message.

## See Also

### Download Authentication

- [download(_:canAuthenticateAgainstProtectionSpace:)](foundation/nsurldownloaddelegate/download(_:canauthenticateagainstprotectionspace:).md)
- [download(_:didReceive:)](foundation/nsurldownloaddelegate/download(_:didreceive:)-1pc0v.md)
- [downloadShouldUseCredentialStorage(_:)](foundation/nsurldownloaddelegate/downloadshouldusecredentialstorage(_:).md)
