0
votes

I'm using Alamofire to upload a several files to my server with separate requests at once, the file names are displayed in a tableView along with a progress bar. When the user tries to delete a file while it's uploading the tableView cell should be removed and the request should be cancelled.

I know the following code is to be used to cancel an Alamofire request:

var request: Alamofire.Request?
self.request?.cancel()

So, I tried making an array of Alamofire.Request like

var requests = [Alamofire.Request]()

And then cancelling the request according to the index.

But this doesn't seem to be the correct way because it's not working, any suggestions?

Thanks.

1

1 Answers

0
votes

According to the documentation cancel would:

Cancels the underlying task, producing an error that is passed to any registered response handlers.

Therefore, add a response handler to your request and see whether error messages are passed to them. If so, it means that the cancel operates correctly.