---
title: "cancel(_:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkdownload/cancel(_:)"
---

# cancel(_:)

Cancels the download, and optionally captures data so that you can resume the download later.

## Declaration

```swift
func cancel(_ completionHandler: (@MainActor @Sendable (Data?) -> Void)? = nil)
```

```swift
func cancel() async -> Data?
```

## Parameters

- `completionHandler`: A closure you provide to capture and store data so that you can resume the download later.

## See Also

### Managing the download

- [delegate](webkit/wkdownload/delegate.md)
- [WKDownload.RedirectPolicy](webkit/wkdownload/redirectpolicy.md)
