How to Stop the Current Http Request in Alamofire using Swift 3

stop HTTP request

In the normal application which is totally based on the Internet means not the offline mode, this types of an application always connect to the internet and make a Http or Https request on every click on the event in an application. some times user don’t want to stay in one controller on clicking the Http request and move to another controller due to that reason two HTTP request going on and response becomes slow so we need to discard the previous network request.

For this, we need to do some

 

1: Make a queue of the network request.

2: Discard the previous request.

For this, we need to do this

write this code in every  UIViewController

 

 

3: You can check whether it is working or not for this:

 

 

Note: error.localizeddescription ¬†will return “cancelled

Now you this in every controller for discard the previous request.

 

 

 

 

 

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close