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

Updated 4 July 2023

Save

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.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home