Skip to content

Commit 78e2f94

Browse files
committed
implement URLSessionDownloadTask.cancel(byProducingResumeData:)
1 parent c91c99d commit 78e2f94

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Foundation/URLSession/URLSessionTask.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,13 @@ open class URLSessionDownloadTask : URLSessionTask {
428428
* If resume data cannot be created, the completion handler will be
429429
* called with nil resumeData.
430430
*/
431-
open func cancel(byProducingResumeData completionHandler: @escaping (Data?) -> Void) { NSUnimplemented() }
431+
open func cancel(byProducingResumeData completionHandler: @escaping (Data?) -> Void) {
432+
super.cancel()
433+
434+
// A token Data value is passed to the client to prevent unexpected
435+
// failures that may be caused by passing nil instead
436+
completionHandler(Data())
437+
}
432438
}
433439

434440
/*

0 commit comments

Comments
 (0)