I am trying to save the downloaded data in download failure case
switch response.result{
case .success( _):
print("success response")
break
case .failure( _):
print("error")
if let resumeData = response.resumeData{
self.resumeData = resumeData
Shared.dataCache.set(value: resumeData, key: self.keyResumeData)
}
}
When I trigger request.Cancel()
using button press event its working perfectly. But when I trigger the same function during appWillTerminate
its not getting into failure case. Is there any way to save downloaded data during App Termination using Alamofire
I think this may work for you:
URLSession.shared.getAllTasks(){
tasks in
tasks.forEach { $0.cancel() }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.