Alamofire Asynchronous requests happening out of o

2019-03-06 12:22发布

I'm having this strange issue with Alamofire asynchronous requests in Swift. Here is the pseudocode for what I am trying to do.

  for each email:
      GET request to grab first_name for email
      add first_name to an array

The issue is that the end array is out of order. When it should be [User 3, User 1, User 2] it is instead [User 3, User 2, User 1]. I've tested my backend funtions with Postman and everything works so am confused as to what exactly is the problem. Any insight into what might be happening or why I am not getting the correct result.

1条回答
ゆ 、 Hurt°
2楼-- · 2019-03-06 12:59

Asynchronous calls are just that. Asynchronous.

You cannot guarantee which one will finish first regardless of the order in which they were started.

查看更多
登录 后发表回答