IOS SDWebImage implementation principle explanation, iossdwebimage

Source: Internet
Author: User

IOS SDWebImage implementation principle explanation, iossdwebimage

 

Before that, I wrote about how to use SDWebImage, mainly to use and obtain network images. If you have not read it, you can check it out.

This article will mainly introduce the implementation principles of SDWebImage, mainly for obtaining the principles of network images. If there is no third party, how should we do it? Of course, I will introduce the knowledge in text, it is not worthwhile for me to spend a lot of time understanding what we cannot use. However, interested friends can go to other blogs to find relevant information. After all, there is no end to learning. Now let's start with the question.

1) when we need to obtain network images, the first thing we need is that there is no URl in the URl. After obtaining the URL, we implement SDWebImage instead of directly requesting the network, check whether there are URl-related images in the image cache. If yes, the system returns the image directly. If no, the system proceeds to the next step.

2) When there is no image in the image cache, SDWebImage will not be retrieved directly from the network, but will check whether there are images in the sandbox, then, save the corresponding image in the sandbox to the image cache and proceed according to the first step.

3) if the sandbox does not exist, the occupied bitmap is displayed, and the image is cached in the download queue to determine whether the image is being downloaded. If the image is downloaded, the system waits to avoid secondary downloads. If not, a download queue is created. After the download is completed, the download operation is cleared from the queue and the image is saved to the image cache.

4) refresh the UI (depending on the actual situation) and save the image to the sandbox cache.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.