AFNetworking prefetch other images

2019-08-22 11:06发布

问题:

I am using the UIImageView + AFNetworking category to download and display images from an array of URLs and populate a table view.

Now I find that the other images are delayed because only the current cell's image will be loaded. I need to keep busy by fetching other images as well.

My idea would be to write a for loop and start downloading and caching with AFNetworking, say, 10 other requests starting from current indexPath.

Or should I just do the usual dispatch_async in the completion block and start fetching the mentioned 20 other images?

Any better ideas?

回答1:

In most cases, pre-fetching won't be nearly as beneficial as you might expect. On a mobile device, power and bandwidth are limited resources, which calls into question the value of loading things that a user may not actually ever see. You're most likely doing a disservice by trying to be clever about this.