objective-c - I now have 10,000 network requests. How can I return a result in the first request, the second request, and so on?
PHPz
PHPz 2017-05-02 09:32:54
0
2
839

My current need is to have 10,000 network requests and have them be executed in order. After requesting the data on the first day, save it to the database, and then request the second one, a one-time question. I wonder if anyone has any ideas? method.

PHPz
PHPz

学习是最好的投资!

reply all(2)
世界只因有你

If your requests are regular, for example, the IDs are consecutive, you can process the ID in the callback or proxy of each successful request before initiating the next request.
A relatively simple and crude way:
Use NSOperationQueue, then set maxConcurrentOperationCount to 1, and add all 10,000 requests. If the executed request has no result, the queue is canceled. However, this saves code but not memory.

phpcn_u1582
function apiCall (i){
    var i = i || 0 ;
    $http.get(i++).then(function(response){
        if(response.status=='ok'){
            apiCall(i);
        }
    },function(error){
        console.log(error);
    });
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template