How to cancel all requests after migrating from Alamofire v3 to v4?
alamofire, swift
Solution
Found:
Alamofire.SessionManager.default.session.getTasksWithCompletionHandler { (sessionDataTask, uploadData, downloadData) in
sessionDataTask.forEach { $0.cancel() }
uploadData.forEach { $0.cancel() }
downloadData.forEach { $0.cancel() }
}
Problem
I used this code to cancel all `Alamofire` requests: ``` func stopAllSessions() { Alamofire.Manager.sharedInstance.session.getAllTasksWithCompletionHandler { tasks in tasks.forEach { $0.cancel() } } } ``` After swift 3 migration, this doesn't work, and I can't find `getAllTasksWithCompletionHandler` method in `SessionManager` of `Alamofire` 4.