我在Swift中遇到了Alamofire异步请求这个奇怪的问题。这是我想要做的伪代码。
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问题是结束数组乱序。当应该是[用户3,用户1,用户2]时,它是[用户3,用户2,用户1]。我已经用Postman测试了我的后端功能,一切正常,所以很困惑究竟是什么问题。任何洞察可能发生的事情或为什么我没有得到正确的结果。
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.
推荐答案异步调用就是这样。 异步。
Asynchronous calls are just that. Asynchronous.
无论启动顺序如何,您都无法保证哪一个会先完成。
You cannot guarantee which one will finish first regardless of the order in which they were started.
更多推荐
Alamofire异步请求在for循环中无序发生
发布评论