I use Alamofire to send a download request. I am handling Success and Failure cases as shown below.
Alamofire.request {
case Success:
// Update UI
case Failure:
// Show Alert message (error!.localizedDescription)
}
Everything is perfectly fine.
When I go back, in viewWillDisappear, I cancel any ongoing request. The issue is, canceling the request throws the error message and that triggers the alert when I am not on that screen.
To my knowledge, I can take two actions.
- Check the condition if the error is created due to request cancel
- Check if the
viewControlleris alive - Also I can set a
Boolvariable inviewWillDisappear, which is a simple solution
How to handle the situation?
Also how to check point 1 & 2?