Previously I used AFNetworking and could easily get all the tasks for current session by tasks
property. I'm trying to migrate to Alamofire 5 and I can't find the same property or way how to get all the tasks.
I create the session like this
let session: Session = {
let configuration = URLSessionConfiguration.af.default
return Session(configuration: configuration)
}()
I'd like to check does my session contain any active tasks
CodePudding user response:
You don't. If you need to perform actions on all of the currently ongoing Request
s, you can use Session.withAllRequests
. If all you need to do is cancel all Request
s you can use Session.cancelAllRequests
. Otherwise you should never access, much less interact with, the URLSessionTask
s that underly an Alamofire Session
.