From 20e69d26d718fc112f9fcd6b7d83b49e6a8ae30a Mon Sep 17 00:00:00 2001 From: philfi Date: Thu, 8 Oct 2020 16:44:53 -0400 Subject: [PATCH] remove manual task clearing URLSession.shared is not being used, calling invalidateAndCancel prior to cleaning up tasks works. --- Sources/Apollo/URLSessionClient.swift | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Sources/Apollo/URLSessionClient.swift b/Sources/Apollo/URLSessionClient.swift index 7d50b629ee..e2b2207728 100644 --- a/Sources/Apollo/URLSessionClient.swift +++ b/Sources/Apollo/URLSessionClient.swift @@ -65,29 +65,15 @@ open class URLSessionClient: NSObject, URLSessionDelegate, URLSessionTaskDelegat self.session = nil self.clearAllTasks() } - + guard let session = self.session else { // Session's already gone, just cleanup. cleanup() return } - - let currentTaskIDs = self.tasks.value.keys - if #available(OSX 10.11, iOS 9.0, *) { - session.getAllTasks { [weak self] tasks in - for task in tasks { - if currentTaskIDs.contains(task.taskIdentifier) { - self?.cancel(task: task) - } - } - - cleanup() - } - } else { - // Fallback on earlier versions - note that per docs this does *not* cancel all operations on the shared session. - session.invalidateAndCancel() - cleanup() - } + + session.invalidateAndCancel() + cleanup() } /// Clears underlying dictionaries of any data related to a particular task identifier.