Afnetworking has the download function, but the download function is relatively basic, in order to implement the complex download function needs to write some code. Today, I found a downloadable open source project on GitHub, which is very good and links to the following: Https://github.com/thibaultCha/TCBlobDownload.
Whether it's afnetworking or the library I mentioned, I used nsoperation, and I took advantage of a key function Nsurlconnection Scheduleinrunloop, which is explained as follows
delegate.
When connection is added to the queue running operation, the thread that runs operation does not end immediately after the request is made, but waits for the callback function to be called, which is the requirement to send and accept network data in an asynchronous thread. If using the Operation function at the same time, only using the normal connection Start method, then only the link request is sent asynchronously, and his callback method will still be executed in the main thread, And it is not possible to limit the number of requests by limiting the number of concurrent operationqueue, because that will only guarantee the concurrent number of simultaneous requests, when the request is made, without waiting for a callback, the thread ends and a new request is made, so that often all requests are sent out quickly, not satisfying the requirements.
IOS recommends a third-party library for download