Multiple request with AFNetworking

前端 未结 2 522
我在风中等你
我在风中等你 2021-02-10 00:31

I\'m trying to do multiple request in background to download many jsons and check data from them but I don\'t know how to use AFNetworking in that case.

I tried to do li

2条回答
  •  无人共我
    2021-02-10 01:28

    Check out AFHTTPClient's enqueueBatchOfHTTPRequestOperations:progressBlock:completionBlock:, which lets you enqueue multiple requests operations at once with the added bonus of having a completion handler that is called when all of those requests have finished, as well as a block for tracking the progress. Also note, that every single operation can still have its own completion handler (useful if you have to process the results of a request, for example).

    If you don't need to customize the request operation (and don't need individual completion blocks), you can also use enqueueBatchOfHTTPRequestOperationsWithRequests:progressBlock:completionBlock:, which allows you to pass an array of NSURLRequest directly without having to build the operations yourself.

提交回复
热议问题